spur18 Posted May 2, 2007 Share Posted May 2, 2007 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 More sharing options...
chronister Posted May 2, 2007 Share Posted May 2, 2007 <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 More sharing options...
spur18 Posted May 2, 2007 Author Share Posted May 2, 2007 <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. Link to comment https://forums.phpfreaks.com/topic/49620-simple-drop-down/#findComment-243286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.