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> Quote Link to comment 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> Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.