0

I am trying to a display options in dropdown by database.Name of table is location and loc is a column in table of varchar datatype

<select style="width: 200px;" name="location" id="myselect" onchange="window.location='enable1.php?id='+this.value+'&pos='+this.selectedIndex;">
  <option value="All">All</option>
  <?php

  $sql="select * from location";
  var_dump($sql);
  $query=mysqli_query($conn,$sql);
  echo "1";
  while($row=mysql_fetch_array($query))
  {
      echo "<option value='$row[loc]'>'$row[loc]'</option>";
  }
    ?>

</select>

But when I load the page I Dont get any output in dropdown. Only 1 option and that is "ALL". Var_dump() also outputs nothing

Prabhjot Singh Kainth
  • 1,831
  • 2
  • 18
  • 26

1 Answers1

1

Remove the single quotes around array keys:

echo "<option value='$row[loc]'>$row[loc]</option>";// line 123
mike.k
  • 3,277
  • 1
  • 12
  • 18