mysql - PHP checkbox updates database but drop drop menu doesn't -


i have following script on checkboxes works , updates database accordingly.

 while($row = mysql_fetch_array($result)){  $host = $row['host']; $environment = $row['environment'];  echo "<tr><td>" . $host . "</td><td>" . $environment . "</td><td><input type='checkbox' name='id[]' value='" . $host . "'/></td></tr>"; }   echo "</tbody></table><input type='submit' value='submit'></form>";  if(gettype($_post['id'])=="array"){ foreach($_post['id'] $val){  $id_c = $val;  $query1 = "update hosts set reboot = 'yes' host='".$id_c."'";  $result= mysql_query($query1);  if($result === false) {     die(mysql_error());  }  echo "reboot updated host " .$id_c. " updated. <br> 

but when replace checkboxes doesn't work. checkbox script below.

while($row = mysql_fetch_array($result)){  $host = $row['host']; $environment = $row['environment'];  echo "<tr><td>" . $host . "</td>       <td><select name='id[".$host."]'><option value='null'>select any</option>                               <option value='dev/qa/test'>dev/qa/test</option>                               <option value='prod/stage'>prod/stage</option>                               </select></td>                               <td>" . $environment . "</td></tr>"; }   echo "</tbody></table><input type='submit' value='submit'></form>";  if (gettype($_post['id'])=="array") {      foreach($_post['id'] $host => $val){              $id_c = $val; if ($val != 'null') {             $query1 = "update hosts set environment = '$val' host='$host'";              $result1 = mysql_query($query1);              if($result1 === false) {              die(mysql_error());          }       echo "environment host " .$host. " updated. <br>";  }}} 

working updated script here now.

in lower script, still use $_post['id'], select field has name select , id field hidden field. values select box never used.

kill <input type='hidden' name='id[]' value='" . $host . "'> , <select name='select'> <select name='id[]'>.

and, please, correct quotes , try have eye on sql injection, script vulnerable that.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -