php - Insert query for new information -


what im trying here is, @ spouse field can update data, , working. @ child field, im trying insert/add new child store in database. insert query not working.

html spouse

 <td colspan="2" class="title_all_u">family member 1 (spouse)</td>     </tr>     <tr>       <td class="pk">family type</td>       <td width="50%" class="pk_2"><input name="spouse_type" type="text" class="textfield_word" id="spouse_type" value="<?php echo $spouse_type ?>" /></td>     </tr>     <tr>       <td class="pk">name</td>       <td width="50%" class="pk_2"><input name="spouse_name" type="text" class="textfield_word" id="spouse_name" value="<?php echo $spouse_name ?>" /></td>     </tr>     <tr>       <td class="pk">gender key</td>       <td class="pk_2"><input type="radio" name="spouse_gender" id="spouse_gender" value="male" <?php if ($spouse_gender=="male"){ ?> checked <?php } ?>/>        male   &nbsp;          <input type="radio" name="spouse_gender" id="spouse_gender" value="female" <?php if ($spouse_gender=="female"){ ?> checked <?php } ?> />       female </td>     </tr>     <tr>       <td class="pk">date of birth</td>       <td class="pk_2"><input name="spouse_date_birth" type="text" class="tcal" id="spouse_date_birth" value="<?php echo date_create($spouse_date_birth)->format('d-m-y');?>" readonly="readonly"/></td>     </tr>     <tr>       <td class="pk">country of birth</td>       <td class="pk_2">       <?php         $query = "select country_type country";         $result = mysql_query ($query); ?>         <select name="spouse_country_birth" >         <?php while($row = mysql_fetch_array($result)){ ?>         <option value="<?php echo $row['country_type']?>"  <?php if ( $spouse_country_birth ==  $row['country_type']){ ?> selected <?php } ?>>         <?php echo $row['country_type']?></option>         <?php }?>         </select>         </td>     </tr>     <tr>       <td class="pk">nationality</td>       <td class="pk_2">         <?php         $query = "select nationality_type nationality";         $result = mysql_query ($query); ?>         <select name="spouse_nationality" >         <?php while($row = mysql_fetch_array($result)){ ?>         <option value="<?php echo $row['nationality_type']?>"  <?php if ( $spouse_nationality ==  $row['nationality_type']){ ?> selected <?php } ?>>         <?php echo $row['nationality_type']?></option>         <?php }?>         </select>         </td>     </tr>     <tr>       <td class="pk">ic number</td>       <td width="50%" class="pk_2"><input name="spouse_ic_num" type="text" class="textfield_word" id="spouse_ic_num" value="<?php echo $spouse_ic_num ?>" /></td>     </tr>     <tr>       <td class="pk">passport no.</td>       <td width="50%" class="pk_2"><input name="spouse_pass_num" type="text" class="textfield_word" id="spouse_pass_num" value="<?php echo $spouse_pass_num ?>" /></td>     </tr>     <tr>       <td class="pk">spouse employed</td>       <td width="50%" class="pk_2"><input name="spouse_employed" type="text" class="textfield_word" id="spouse_employed" value="<?php echo $spouse_employed ?>" /></td>     </tr>     <tr>       <td class="pk">job title</td>       <td width="50%" class="pk_2"><input name="spouse_job_title" type="text" class="textfield_word" id="spouse_job_title" value="<?php echo $spouse_job_title ?>" /></td>     </tr>     <tr>       <td class="pk">spouse employer</td>       <td width="50%" class="pk_2"><input name="spouse_employer" type="text" class="textfield_word" id="spouse_employer" value="<?php echo $spouse_employer ?>" /></td>     </tr> 

html child

<td colspan="2" class="title_all_u">family member 2 (child)</td>     </tr>     <tr>       <td width="50%" class="pk">family type</td>       <td width="50%" class="pk_2"><input name="family_child_type" type="text" class="textfield_word" id="family_child_type" value="" /></td>     </tr>     <tr>       <td class="pk">name</td>       <td width="50%" class="pk_2"><input name="family_child_name" type="text" class="textfield_word" id="family_child_name" value="" /></td>     </tr>     <tr>       <td class="pk">gender key</td>       <td class="pk_2">       <input type="radio" name="family_child_gender" id="family_child_gender" value="male" <?php if ($family_child_gender=="male"){ ?> checked <?php } ?>/>        male   &nbsp;          <input type="radio" name="family_child_gender" id="family_child_gender" value="female" <?php if ($family_child_gender=="female"){ ?> checked <?php } ?> />       female         </td>     </tr>     <tr>       <td class="pk">date of birth</td>       <td class="pk_2"><input name="family_child_date_birth" type="text" class="tcal" id="family_child_date_birth" value="<?php echo date_create("")->format('d-m-y');?>" readonly="readonly"/></td>     </tr>     <tr>       <td class="pk">country of birth</td>       <td class="pk_2">       <?php         $query = "select country_type country";         $result = mysql_query ($query); ?>         <select name="family_child_country" >         <?php while($row = mysql_fetch_array($result)){ ?>         <option value="<?php echo $row['country_type']?>"  <?php if ( $family_child_country ==  $row['country_type']){ ?> selected <?php } ?>>         <?php echo $row['country_type']?></option>         <?php }?>         </select>         </td>     </tr>     <tr>       <td class="pk">nationality</td>       <td class="pk_2">         <?php         $query = "select nationality_type nationality";         $result = mysql_query ($query); ?>         <select name="family_child_nationality" >         <?php while($row = mysql_fetch_array($result)){ ?>         <option value="<?php echo $row['nationality_type']?>"  <?php if ( $family_child_nationality ==  $row['nationality_type']){ ?> selected <?php } ?>>         <?php echo $row['nationality_type']?></option>         <?php }?>         </select>         </td>     </tr>     <tr>       <td class="pk">ic number</td>       <td width="50%" class="pk_2"><input name="$family_child_ic_num" type="text" class="textfield_word" id="$family_child_ic_num" value="" /></td>     </tr>     <tr>       <td class="pk">passport no.</td>       <td width="50%" class="pk_2"><input name="family_child_pass_num" type="text" class="textfield_word" id="family_child_pass_num" value="" /></td>     </tr>     <tr>       <td class="pk">education/training</td>       <td width="50%" class="pk_2"><input name="family_child_education" type="text" class="textfield_word" id="family_child_education" value="" /></td>     </tr>     <tr>       <td class="pk">handicapped</td>       <td width="50%" class="pk_2"><input name="family_child_handicaped" type="text" class="textfield_word" id="family_child_handicaped" value="" /></td>     </tr>     <tr>       <td class="pk">child custody</td>       <td width="50%" class="pk_2"><input name="family_child_custody" type="text" class="textfield_word" id="family_child_custody" value="" /></td>     </tr>     <tr>       <td class="pk">married</td>        <td class="pk_2">        <input type="radio" name="family_child_married_status" id="family_child_married_status" value="yes" <?php if ($family_child_married_status=="yes"){ ?> checked <?php } ?>/>        yes   &nbsp;          <input type="radio" name="family_child_married_status" id="family_child_married_status" value="no" <?php if ($family_child_married_status=="no"){ ?> checked <?php } ?> />       no  </td>     </tr>     <tr>       <td class="pk">employed</td>       <td width="50%" class="pk_2"><input name="family_child_employed" type="text" class="textfield_word" id="family_child_employed" value="" /></td>     </tr> 

update query spouse (working)

$spouse_type = $_post['spouse_type']; $spouse_name = $_post['spouse_name']; $spouse_gender = $_post['spouse_gender']; $spouse_date_birth = $_post['spouse_date_birth']; $spouse_country_birth = $_post['spouse_country_birth']; $spouse_nationality = $_post['spouse_nationality']; $spouse_ic_num = $_post['spouse_ic_num']; $spouse_pass_num = $_post['spouse_pass_num']; $spouse_employed = $_post['spouse_employed']; $spouse_job_title = $_post['spouse_job_title']; $spouse_employer = $_post['spouse_employer'];   mysql_query("update family_spouse set spouse_type = '".mysql_real_escape_string($_post["spouse_type"])."', spouse_name = '".mysql_real_escape_string($_post["spouse_name"])."', spouse_gender = '".mysql_real_escape_string($_post["spouse_gender"])."', spouse_date_birth = str_to_date('".mysql_real_escape_string($_post["spouse_date_birth"])."','%d-%m-%y'), spouse_country_birth = '".mysql_real_escape_string($_post["spouse_country_birth"])."', spouse_nationality = '".mysql_real_escape_string($_post["spouse_nationality"])."', spouse_ic_num = '".mysql_real_escape_string($_post["spouse_ic_num"])."', spouse_pass_num = '".mysql_real_escape_string($_post["spouse_pass_num"])."', spouse_employed = '".mysql_real_escape_string($_post["spouse_employed"])."', spouse_job_title = '".mysql_real_escape_string($_post["spouse_job_title"])."', spouse_employer = '".mysql_real_escape_string($_post["spouse_employer"])."' las_login_id = '".mysql_real_escape_string($_post["las_login_id"])."'"); 

insert query child (not working)

$family_child_type = $_post['family_child_type']; $family_child_name = $_post['family_child_name']; $family_child_gender = $_post['family_child_gender']; $family_child_date_birth = $_post['family_child_date_birth']; $family_child_country = $_post['family_child_country']; $family_child_nationality = $_post['family_child_nationality']; $family_child_ic_num = $_post['family_child_ic_num']; $family_child_pass_num = $_post['family_child_pass_num']; $family_child_education = $_post['family_child_education']; $family_child_handicaped = $_post['family_child_handicaped']; $family_child_custody = $_post['family_child_custody']; $family_child_married_status = $_post['family_child_married_status']; $family_child_employed = $_post['family_child_employed'];    $sql="insert family_child (family_child_type, family_child_name, family_child_gender, family_child_date_birth, family_child_country, family_child_nationality, family_child_ic_num, family_child_pass_num, family_child_education, family_child_handicaped, family_child_custody, family_child_married_status, family_child_employed) values (family_child_type = '".mysql_real_escape_string($_post["family_child_type"])."', family_child_name = '".mysql_real_escape_string($_post["family_child_name"])."', family_child_gender = '".mysql_real_escape_string($_post["family_child_gender"])."', family_child_date_birth = str_to_date('".mysql_real_escape_string($_post["family_child_date_birth"])."','%d-%m-%y'), family_child_country = '".mysql_real_escape_string($_post["family_child_country"])."', family_child_nationality = '".mysql_real_escape_string($_post["family_child_nationality"])."', family_child_ic_num = '".mysql_real_escape_string($_post["family_child_ic_num"])."', family_child_pass_num = '".mysql_real_escape_string($_post["family_child_pass_num"])."', family_child_education = '".mysql_real_escape_string($_post["family_child_education"])."', family_child_handicaped = '".mysql_real_escape_string($_post["family_child_handicaped"])."', family_child_custody = '".mysql_real_escape_string($_post["family_child_custody"])."', family_child_married_status = '".mysql_real_escape_string($_post["family_child_married_status"])."', family_child_employed = '".mysql_real_escape_string($_post["family_child_employed"])."')";  

thanks answer.

to update spouse information executing query insert child information did not execute query.

add following line after $sql="insert family_child (family_child_type, .......

mysql_query($sql); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -