illuz1on Posted April 26, 2007 Share Posted April 26, 2007 hey I have a listbox called "I want to..." and people select in the listbox what they want to do and then the selection links to x.php ... This code only shows 1 entry in the listbox while the database has more <?php include("db.php"); ?> <html> <body> <?php //select statement example ok all book entry's lol. $sql = "SELECT * FROM guides"; $data = mysql_query($sql); while($record = mysql_fetch_assoc($data)) { $id = $record['id']; $name = $record['name']; $link = $record['link']; } echo "<form name=\"guideform\" id=\"guideform\" action=\"#\"> <select name=\"guidelinks\" id=\"guidelinks\" onChange=\"window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value\"> <option selected value=\"#\">I want a</option> <option value=\"$link.php\">$name</option> </select> </form> "; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/48757-listbox-only-showing-1/ Share on other sites More sharing options...
ToonMariner Posted April 26, 2007 Share Posted April 26, 2007 you are missing a loop. fundamental in outputting numerous records form a database... Don't be scared to break out of php, its no big deal... <?php include("db.php"); ?> <html> <body> <?php //select statement example ok all book entry's lol. $sql = "SELECT * FROM guides"; $data = mysql_query($sql); } ?> <form name="guideform" id="guideform" action="#"> <select name="guidelinks" id="guidelinks" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> <option selected value="#">I want a</option> <?php while($record = mysql_fetch_assoc($data)) { echo '<option value="'.$record['link'].'">'.$record['name'].'</option>'; } ?> </select> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/48757-listbox-only-showing-1/#findComment-238957 Share on other sites More sharing options...
illuz1on Posted April 26, 2007 Author Share Posted April 26, 2007 good to know that thanks alot mate Link to comment https://forums.phpfreaks.com/topic/48757-listbox-only-showing-1/#findComment-238967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.