Wednesday, October 29, 2014

Create MySQL trigger

Create MySQL trigger

For update
CREATE TRIGGER TRG_tableA_Insert
AFTER INSERT
   ON tableA FOR EACH ROW
BEGIN
  UPDATE tableB
  set   columnA = NEW.columnX,
        columnB = NEW.columnY,
  WHERE columnB = NEW.columnY;
END;

For insert
CREATE TRIGGER TRG_tableA_Insert
AFTER INSERT
   ON tableA FOR EACH ROW
BEGIN
  INSERT INTO tableB(columnA, columnB)
  VALUES ( NEW.columnX, NEW. columnY);
END;

Wednesday, April 9, 2014

Bootstrap sample layout

http://bit.ly/1n1cKke

HTML page layout

Ref: http://stackoverflow.com/questions/19192211/css-how-to-style-a-footer

html, body {
 height: 100%;
 margin: 0;
}

main {
 min-height: 100%;
 margin-bottom: -10px;
 background: #ddd;
 width: 600px; margin: 0 auto -10px;
}

main:after {
 content: "";
 display: block;
 height: 10px;
}

footer {
 height: 10px;
 background: #eee;
 width: 600px;
 margin: 0 auto -10px;
}

Tuesday, April 8, 2014

How to unset form values after success


 $this->load->library('form_validation');

    $this->form_validation->set_rules('firstname', 'First Name', 'required');
    $this->form_validation->set_rules('surname', 'Sur Name', 'required');

    if ($this->form_validation->run() === TRUE)
    {
                    // save data

        $this->session->set_flashdata('message', 'New Contact has been added');
        redirect(current_url());
    }

    $this->load->view('contacts/add', $this->data);

Monday, April 7, 2014

jQuery validation plugin example

URL: http://jqueryvalidation.org/

 $(document).ready(function() {
        $("#frm").validate({
            errorClass: 'error',
            rules: {
                name: {
                    required:true,
                    alphanumeric: true
                },
                email: {
                    required: true,
                    email: true
                },
                address: "required"
            },
            messages: {
                name:{
                    alphanumeric: "Alphanumeric charactors only...!"
                },
                email: {
                    required: "We need your email address to contact you",
                    email: "Your email address must be in the format of name@domain.com"
                }              
            }
        });
    });