Toy Posted September 12, 2010 Share Posted September 12, 2010 I have a "select"-drop down bar and I want to have a numbered list in it, i've tried but it doesn't seem to be possible. Is there any way that i'm able to do this? Link to comment https://forums.phpfreaks.com/topic/213243-list-in-drop-down-bar/ Share on other sites More sharing options...
Hypnos Posted September 12, 2010 Share Posted September 12, 2010 Yes, it's possible. Just echo <option value="get/post value">Number - value</option> as you're looping through your data. Need to show your code for anything more specific. Link to comment https://forums.phpfreaks.com/topic/213243-list-in-drop-down-bar/#findComment-1110340 Share on other sites More sharing options...
Toy Posted September 16, 2010 Author Share Posted September 16, 2010 Hmm.. I don't really understand but thanks for your time. My code goes along those lines.. <?php if(isset($_GET['id'])) { $result = mysql_query("SELECT * FROM table WHERE id='" . mysql_real_escape_string($_GET['id']) . "'"); while($display = mysql_fetch_array($result)) { echo '<option value="'. $display['id'] .'">'. $display['title'] .'</option>'; } } else { } ?> Link to comment https://forums.phpfreaks.com/topic/213243-list-in-drop-down-bar/#findComment-1111789 Share on other sites More sharing options...
Andy-H Posted September 16, 2010 Share Posted September 16, 2010 <?php if(isset($_GET['id'])) { $result = mysql_query("SELECT * FROM table WHERE id='" . mysql_real_escape_string($_GET['id']) . "'"); $i = 1; while($display = mysql_fetch_array($result)) { echo "\t" . '<option value="' . $display['id'] . '">' . $i . ' - ' . $display['title'] . '</option>' . "\r\n"; $i++; } } else { } ?> Link to comment https://forums.phpfreaks.com/topic/213243-list-in-drop-down-bar/#findComment-1111796 Share on other sites More sharing options...
Toy Posted September 16, 2010 Author Share Posted September 16, 2010 <?php if(isset($_GET['id'])) { $result = mysql_query("SELECT * FROM table WHERE id='" . mysql_real_escape_string($_GET['id']) . "'"); $i = 1; while($display = mysql_fetch_array($result)) { echo "\t" . '<option value="' . $display['id'] . '">' . $i . ' - ' . $display['title'] . '</option>' . "\r\n"; $i++; } } else { } ?> Works like a charm! Thank you. Link to comment https://forums.phpfreaks.com/topic/213243-list-in-drop-down-bar/#findComment-1111829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.