suelow
asked on
pull data from DB to a drop down list ..
Hi,
I'm a ASP programmer.. and I"m very new in php.
May I know how to pull data from a table and output it in a drop down list ??
<select name=glass>
<?php
$db = mysql_connect("localhost", "root", "");
mysql_select_db("Optics",$ db);
$result=mysql_query("selec t glass from Glass");
// from here how to continue ??
?>
</select>
I found that php got no EOF() function .. how to use loop to display the data in a drop down list ?? Please advice..
Thanks
I'm a ASP programmer.. and I"m very new in php.
May I know how to pull data from a table and output it in a drop down list ??
<select name=glass>
<?php
$db = mysql_connect("localhost",
mysql_select_db("Optics",$
$result=mysql_query("selec
// from here how to continue ??
?>
</select>
I found that php got no EOF() function .. how to use loop to display the data in a drop down list ?? Please advice..
Thanks
Adjust lokeshv code to your like this:
<select name=glass>
<?php
$db = mysql_connect("localhost", "root", "");
mysql_select_db("Optics",$ db);
$result=mysql_query("selec t glass from Glass");
// Data found in the resultset?
if($info = mysql_fetch_array($result) )
{
// Loop through each row in the resultset.
do
{
echo "<option value=\"".$info["glass"]." \">".$info ["glass"]. "</option> \n";
}while($info = mysql_fetch_array($result) );
}
?>
</select>
<select name=glass>
<?php
$db = mysql_connect("localhost",
mysql_select_db("Optics",$
$result=mysql_query("selec
// Data found in the resultset?
if($info = mysql_fetch_array($result)
{
// Loop through each row in the resultset.
do
{
echo "<option value=\"".$info["glass"]."
}while($info = mysql_fetch_array($result)
}
?>
</select>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Rajko: You should NOT propose answer on something that does the same as the comment posted previously. Now, you have locked the question!
Why not just post comments and let the user asking the question evaluates them and then accept the one he likes best as an answer???
Batalf
Why not just post comments and let the user asking the question evaluates them and then accept the one he likes best as an answer???
Batalf
strange....
btw wat did u find in his code ?
Lk
btw wat did u find in his code ?
Lk
I agree with you lokeshv. The only result of this question is as far as I can see that Rajko could continue his annoying habit of proposing answers on question whene he shouldn't.
Yeah Baltaf yor are right.
this is really annoying somone comes and directly post the answer when already two comments have been posted into the quesation and his answer is nothing diferent..
Lk
this is really annoying somone comes and directly post the answer when already two comments have been posted into the quesation and his answer is nothing diferent..
Lk
<?whiler($row=mysql_fetch_
<option value="<?=$row[field1]?>">
<?}?>
</select> //end of ur select
Hope this helps...
LK