Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php code not converting to html

Tags:

html

php

I have a php code

<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>

In this code i echo"options" but instead of that when I view source code I see php part written not options..

like image 910
Prabhjot Singh Kainth Avatar asked Feb 22 '26 03:02

Prabhjot Singh Kainth


1 Answers

You used mysql_fetch_array() instead of mysqli_fetch_array()... Try this...

<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=mysqli_fetch_array($query))
  {
      echo "<option value='$row[loc]'>'$row[loc]'</option>";
  }
    ?>

</select>

let me know if it helps...

like image 108
Tanvir Ahmad Sohan Avatar answered Feb 23 '26 17:02

Tanvir Ahmad Sohan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!