Dear Friend,
I create a dropdown list and want to retrieve data(company name list) from MYSQL to this dropdown list ,please, help me.no error but data does not show.
code is bellow

Company Name:          
<?php
include "conn.php";
  $sql="SELECT * FROM login1 ";
  $result=$conn->query($sql);
  echo "<select name=cn value=''>Company Name</option>"; // list box select command
foreach ($conn->query($sql) as $row){//Array or records stored in $row
echo "<option value='$row[id]'></option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box <br>
?>     <br>

please help me.

Recommended Answers

All 5 Replies

ok i solved problem thx all

Can you share how you solved it as it may help someone else?

Share your success!!

yes ,

  echo "<select name=cn value=''>Company Name</option>"; // list box select command
foreach ($conn->query($sql) as $row){//Array or records stored in $row
echo "<option value='$row[id]'>$row[name]</option>";*/ here put $row[name]
/* Option values are added by looping through the array */
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.