Jump to content

simple drop down


spur18

Recommended Posts

Hi,

 

I'm still kind of new to php, and a little help would be appreicated. :)

Basically all I need is for the code below, to actually take all the categorys in the mysql table, currently it only grabs the first one ID=1 default. So basically as a drop down opition it will be value=1 Default. I've added a second one. value 2, test, and would like to loop this.

 

                           

<p><select name="vcatnew" size="1">

<?

$q1 = "select * from fsr_cat order by cid";

$r1 = mysql_query($q1) or die(mysql_error());

$a1 = mysql_fetch_array($r1);

echo "<option value=$a1[cid]>$a1[catname]</option>";?>

</select></p>

 

Thanks for any help you can provide.

Ciao,

Shawn

 

 

Link to comment
https://forums.phpfreaks.com/topic/49620-simple-drop-down/
Share on other sites

<p><select name="vcatnew" size="1">

<?

$q1 = "select * from fsr_cat order by cid";

$r1 = mysql_query($q1) or die(mysql_error());

  while($a1=mysql_fetch_array($r1)) // ya gotta loop through all results

    {

        echo "<option value=$a1[cid]>$a1[catname]</option>";

      }

?>

</select></p>

Link to comment
https://forums.phpfreaks.com/topic/49620-simple-drop-down/#findComment-243284
Share on other sites

<p><select name="vcatnew" size="1">

<?

$q1 = "select * from fsr_cat order by cid";

$r1 = mysql_query($q1) or die(mysql_error());

   while($a1=mysql_fetch_array($r1)) // ya gotta loop through all results

     {

        echo "<option value=$a1[cid]>$a1[catname]</option>";

      }

?>

</select></p>

 

ahhh god I feel like a moron, works perfectly Thanks. :P:D

Link to comment
https://forums.phpfreaks.com/topic/49620-simple-drop-down/#findComment-243286
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.