PHP MySQL Insert from drop down menu -


just quick question. sure not complicated think. have page has 4 drop down menus. these populated database mysql. upon submission these options inserted different table. life of me can no figure out. please if let me know bit of code achieve appreciated. have been attempting day or now. in advance help. note these snippets of code. might not have closing tags etc.

php code:

    <?php  //connecting db $myserver   = ""; $myusername = ""; $mypassword = ""; $mydatabase = "";  $myquery1   = "select dispatchurgency.dispatchurgencyid, dispatchurgency.dispatchurgencyname dispatchurgency order dispatchurgency.dispatchurgencyname"; $myquery2   = "select dispatchstatus.dispatchstatusid, dispatchstatus.dispatchstatusname dispatchstatus order dispatchstatus.dispatchstatusid"; $myquery3   = "select installer.installerid, concat_ws(' ', packingsliplocation.contactname, installer.installerregion, packingsliplocation.contactphone) expr1 packingsliplocation inner join installer on packingsliplocation.packingsliplocationid=installer.installerpackingsliplocationid"; $myquery4   = "select location.locationid, concat_ws(' ', systemname, id1poc, sitenamelocation, siteaddress1) expr2 location"; $myquery5   = "select dispatchurgency.dispatchurgencyid dispatchurgency dispatchurgencyname = '".$_post['element_11']."'";  $myconnection = mysql_connect($myserver,$myusername,$mypassword); if (!$myconnection){    die('conncetion failed:' . mysql_error()  ); } @mysql_select_db($mydatabase) or die("unable select database");   $result1 = mysql_query($myquery1) or die (mysql_error()); $result2 = mysql_query($myquery2) or die (mysql_error()); $result3 = mysql_query($myquery3) or die (mysql_error()); $result4 = mysql_query($myquery4) or die (mysql_error()); $options = "";  if(mysql_num_rows($result1)){  $select1= '<select name="element_11" class="element select large" id="element_11">';    while($rs=mysql_fetch_array($result1)){        $select1.='<option value="'.$rs['dispatchurgencyid'].'">'.$rs['dispatchurgencyname'].'</option>';    }  }  $select1.='</select>';    if(mysql_num_rows($result2)){  $select2= '<select class="element select large" id="element_12" name="element_12">';    while($rs=mysql_fetch_array($result2)){        $select2.='<option value="'.$rs['dispatchstatusid'].'">'.$rs['dispatchstatusname'].'</option>';    }  }  $select2.='</select>';   if(mysql_num_rows($result3)){  $select3= '<select class="element select large" id="element_13" name="element_13">';    while($rs=mysql_fetch_array($result3)){        $select3.='<option value="'.$rs['installer.installerid'].'">'.$rs['expr1'].'</option>';    }  }  $select3.='</select>';   if(mysql_num_rows($result4)){  $select4= '<select class="element select large" id="element_14" name="element_14">';    while($rs=mysql_fetch_array($result4)){        $select4.='<option value="'.$rs['installer.installerid'].'">'.$rs['expr2'].'</option>';    }  }  $select4.='</select>';  ?> 

html form:

<form id="form_631187" class="appnitro"  method="post" action="">         <div class="form_description">             <h2>dispatch form</h2>         </div>                             <ul>          <li id="li_1" >         <label class="description" for="element_1">dispatch id </label>         <div>             <input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>          </div>          </li>       <li id="li_11" >         <label class="description" for="element_11">urgency</label>         <div>           <?php echo $select1; ?>          </div>          </li>                <li id="li_12" >          <label class="description" for="element_12">status</label>          <div>          <?php echo $select2; ?>          </div>           </li>                <li id="li_13" >          <label class="description" for="element_13">installers</label>          <div>             <?php echo $select3; ?>          </div>           </li>            <li id="li_14" >          <label class="description" for="element_14">location </label>          <div>          <?php echo $select4; ?>          </div>           </li>    

2 things noticed:

<form id="form_631187" class="appnitro"  method="post" action=""> 

has no action parameter. need put like:

<form id="form_631187" class="appnitro"  method="post" action="form_handler.php"> 

then need create form_handler.php , forms contents in $_post array. on page create need update/insert table holds values in form.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -