javascript - How to post values to database with php from options dynamically created with php -


sorry obtuse title not quite sure how describe one. have options dynamically created through call database php. dropdown list options set this:

<div class="input-group col-md-12"><span class="input-group-addon">tag source</span>     <select class="form-control" name="tagtype" value="<?php echo addslashes($_post['tagtype']); ?>">         <option value="">tag source</option>         <?php         foreach ($sources $row) {         ?>         <option value="'".<?php $row['sources']; ?>."'"><?php echo $row['sources']; ?></option>         <?php         }         ?> 

when update database thought update value have set php:

<option value="'".<?php $row['sources']; ?>."'"> 

but instead not update database properly. guess have write javascript function set value post db welcome instruction!

edit: how update database

$conn = new mysqli(intentionally left blank); include('login.php');    if($_post['submit']) {     if ($_post['tagname']=="") $error.="<br />please enter tag name!";     if ($_post['tagtype']=="") $error.="<br />please enter tag type!";     if ($_post['url']=="") $error.="<br />please enter tag url!";     if ($_post['publisher']=="") $error.="<br />please enter publisher!";     if ($_post['advertiser']=="") $error.="<br />please enter advertiser!";     if ($_post['identifier']=="") $error.="<br />please enter id!";     if ($_post['ecpm']=="") $error.="<br />please enter ecpm rate!";     if ($_post['ccpm']=="") $error.="<br />please enter ecpm rate!";     if ($_post['datebrokered']=="") $error.="<br />please enter date brokered!";     else {         if (mysqli_connect_error()) {         printf("connect failed: %s\n", mysqli_connect_error());         exit();       }          $identifier = $_post['identifier'];         $sql = "select unique_id jpctags identifier=?";         $stmt = $conn -> prepare($sql);         $stmt -> bind_param('s',$identifier);         $stmt -> execute();         $stmt -> store_result();         $stmt -> bind_result($uniqueid);         $stmt -> fetch();          if ($uniqueid) $error = "this tag exits within system, please edit tag instead.";         else {              $tagname = $_post['tagname'];             $tagtype = $_post['tagtype'];             $identifier = $_post['identifier'];             $url = $_post['url'];             $publisher = $_post['publisher'];             $advertiser = $_post['advertiser'];             $ecpm = $_post['ecpm'];             $ccpm = $_post['ccpm'];             $datebrokered = $_post['datebrokered'];              $sql = "insert jpctags (`tagname`, `tagtype`, `identifier`, `url`, `publisher`, `advertiser`, `ecpm`, `ccpm`, `datebrokered`, `user_id`) values(?,?,?,?,?,?,?,?,?,?)";             $stmt = $conn -> prepare($sql);             $stmt -> bind_param('ssssssiisi',$tagname, $tagtype, $identifier, $url, $publisher, $advertiser, $ecpm, $ccpm, $datebrokered, $user_id);             $stmt -> execute();          }       }     } 

you returning row tables values option. should echo them:

<option value="<?php echo $row['sources']; ?>"> 

Comments