lewis987 Posted June 23, 2007 Share Posted June 23, 2007 i have a selection box that should show up all the items i have in the database, but instead its only showing one. Code below <?PHP $themes=$prefix."themes"; $themeboxsql="SELECT * FROM $themes LIMIT 0,100"; $themeboxresult=mysql_query($themeboxsql); $themes=mysql_fetch_array($themeboxresult); ?> <form action="?idx&st=<?PHP echo $themes['id'] ?>" method="post"> <select name="theme"> <option class="tbl">--Themes--</option> <option value="<?PHP echo $themes['id']; ?>" class="tbl2"><?PHP echo $themes['name'] ?></option> </select> <input name="go" type="image" width="12" height="12" title="Change Skin" src="<?PHP echo $path2; ?>img/go.gif" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/ Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 You need a while loop: <?php $themes=$prefix."themes"; $themeboxsql="SELECT * FROM $themes LIMIT 0,100"; $themeboxresult=mysql_query($themeboxsql); ?> <form action="?idx&st=<?PHP echo $themes['id'] ?>" method="post"> <select name="theme"> <option class="tbl">--Themes--</option> <?php while ($themes=mysql_fetch_assoc($themeboxresult)){ echo "<option value='{$themes['id']}' class='tbl2'>{$themes['name']}</option>"; } ?> </select> <input name="go" type="image" width="12" height="12" title="Change Skin" src="<?PHP echo $path2; ?>img/go.gif" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/#findComment-280964 Share on other sites More sharing options...
lewis987 Posted June 23, 2007 Author Share Posted June 23, 2007 ill try it not working fully i have 3 entries and its only showing 2 :S Quote Link to comment https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/#findComment-280965 Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 Try changing this: $themeboxsql="SELECT * FROM $themes LIMIT 0,100"; To: $themeboxsql="SELECT * FROM $themes LIMIT 100"; The "0" isn't really necessary. I don't think that would cause it to skip any rows in the DB, but it's worth a try. Are you sure you are not calling the missing row in a query earlier in your script (if there is code above what you posted)? Quote Link to comment https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/#findComment-280977 Share on other sites More sharing options...
lewis987 Posted June 23, 2007 Author Share Posted June 23, 2007 well doesnt make a difference but here is the full code of my footer (it gets inculded in the main page) page: the part that im having trouble with is near the end the main problem is its not showing the very first result <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td valign="middle" width="100px"> <?PHP $themes=$prefix."themes"; $themeboxsql="SELECT * FROM $themes LIMIT 100"; $themeboxresult=mysql_query($themeboxsql); $themes=mysql_fetch_array($themeboxresult); ?> <form action="<?PHP $PHP_SELF; ?>?idx&st=<?PHP echo $themes['id'] ?>" method="post"> <select name="theme"> <option class="tbl">--Themes--</option> <?php while ($themes=mysql_fetch_array($themeboxresult)){ echo "<option value='{$themes['id']}' class='tbl2'>{$themes['name']}</option>"; } ?> </select> <input name="go" type="image" width="12" height="12" title="Change Skin" src="<?PHP echo $path2; ?>img/go.gif" /> </form> </td> <td> </td> </tr> </table> <?PHP if($user){ ?> <table width="100%" border="0"> <tr> <td width="13%"><a href="http://www.php.net" onMouseOver="image1.src=loadImage1.src;" onMouseOut="image1.src=staticImage1.src;" target="_blank"><img src="<?PHP echo $path2;?>img/php-gray.gif" name="image1" width="90" height="50" border=0></a></td> <td width="14%"><a href="http://www.mysql.com" onMouseOver="image2.src=loadImage2.src;" onMouseOut="image2.src=staticImage2.src;" target="_blank"><img src="<?PHP echo $path2;?>img/mysql-color.gif" name="image2" border=0></a></td> <td width="46%"> </td> <td width="14%"><a href="http://www.mysql.com" onMouseOver="image3.src=loadImage3.src;" onMouseOut="image3.src=staticImage3.src;" target="_blank"><img src="<?PHP echo $path2;?>img/mysql-color.gif" name="image3" border=0></a></td> <td width="13%"><a href="http://www.php.net" onMouseOver="image4.src=loadImage4.src;" onMouseOut="image4.src=staticImage4.src;" target="_blank"><img src="<?PHP echo $path2;?>img/php-gray.gif" name="image4" width="90" height="50" border=0></td> </tr> </table> <?PHP }else{ ?> <table width="100%" border="0"> <tr> <td width="13%"><a href="http://www.php.net" onMouseOver="image1.src=loadImage1.src;" onMouseOut="image1.src=staticImage1.src;" target="_blank"><img src="<?PHP echo $path1;?>img/php-gray.gif" name="image1" width="90" height="50" border=0></a></td> <td width="14%"><a href="http://www.mysql.com" onMouseOver="image2.src=loadImage2.src;" onMouseOut="image2.src=staticImage2.src;" target="_blank"><img src="<?PHP echo $path1;?>img/mysql-color.gif" name="image2" border=0></a></td> <td width="46%"> </td> <td width="14%"><a href="http://www.mysql.com" onMouseOver="image3.src=loadImage3.src;" onMouseOut="image3.src=staticImage3.src;" target="_blank"><img src="<?PHP echo $path1;?>img/mysql-color.gif" name="image3" border=0></a></td> <td width="13%"><a href="http://www.php.net" onMouseOver="image4.src=loadImage4.src;" onMouseOut="image4.src=staticImage4.src;" target="_blank"><img src="<?PHP echo $path1;?>img/php-gray.gif" name="image4" width="90" height="50" border=0></td> </tr> </table> <?PHP } ?> </body> </html> yes its messy but i will sort it out... Quote Link to comment https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/#findComment-280993 Share on other sites More sharing options...
lewis987 Posted June 23, 2007 Author Share Posted June 23, 2007 solved it myself Quote Link to comment https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/#findComment-281049 Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 Just out of curiosity, what was the problem? Quote Link to comment https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/#findComment-281050 Share on other sites More sharing options...
lewis987 Posted June 23, 2007 Author Share Posted June 23, 2007 it didnt want to show the first table row for some reason, i rewrote the code and it now works Quote Link to comment https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/#findComment-281058 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.