title: How do I store value in my database in a dynamic dropdown list?
body: <p><strong>This is a dynamic dropdown in PHP/mySQL.</strong>
  I want to store the name in the database server but the  tag outputs the integer value. </p>
  
  <p>If i change the code from <code>&lt;option value="&lt;?php echo $row["id"]; ?&gt;"&gt;</code> to <code>&lt;option value="&lt;?php echo $row["name"]; ?&gt;"&gt;</code> It shows my_sqli_fetch_array expects parameter 1 error.</p>
  
  <p>My objective being to store the corresponding $row["name"] that is being displayed on the dropdown instead of $row["id"]. </p>
  
  <pre><code>&lt;?php
  
  $link = mysqli_connect("localhost","root", "");
  mysqli_select_db($link,"loginsystem");
  
  ?&gt;
  
  &lt;form name="form1" action="" method="post"&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;Select Assembly Line&lt;/td&gt;
  &lt;td&gt;&lt;select id ="assemblylinedd" onChange="change_assemblyline()"&gt;
  &lt;option&gt;Select&lt;/option&gt;
  
  &lt;?php
  $i=1;
  $res=mysqli_query($link, "SELECT * FROM assemblyline");
  $count=mysqli_num_rows($res);
  if ($count &gt;0){
  while($row=mysqli_fetch_array($res))
  {
  ?&gt;
  &lt;option value="&lt;?php echo $row["id"]; ?&gt;"&gt;&lt;?php echo $row["name"]; ?&gt;&lt;/option&gt;
  }
  
  &lt;?php $i++;} }else{
  echo "No record Found !";
  } ?&gt;
  
  &lt;/select&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>Scripting code :</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function change_assemblyline()
  {
      var xmlhttp = new XMLHttpRequest();
      xmlhttp.open("GET","ajax.php?assemblyline="+document.getElementById("assemblylinedd").value, false);
      xmlhttp.send(null);
      alert(xmlhttp.responseText);
      document.getElementById("devices").innerHTML=xmlhttp.responseText;
  
  }
  </code></pre>
  
  <p>This is my ajax.php</p>
  
  <pre><code>$link = mysqli_connect("localhost","root", "");
  mysqli_select_db($link,"loginsystem");
  
  $assemblyline = isset($_GET['assemblyline']) ? $_GET['assemblyline'] : '';
  $devices = isset($_GET['devices']) ? $_GET['devices'] : '';
  
  
  if($assemblyline!="")
  {   
  
      $res=mysqli_query($link, "SELECT * FROM devices WHERE devices_id=$assemblyline");
      echo "&lt;select id='devicesdd' onchange='change_devices()'&gt;";
      while($row=mysqli_fetch_array($res))
  
      {
  
      echo "&lt;option value='$row[id]'&gt;";echo $row["name"]; echo "&lt;/option&gt;";
  
      }
      echo "&lt;/select&gt;";
  
  }
  </code></pre>
  
  <p>Please do ignore onchange_devices() as it follows the same for next consecutive dropdown.</p>