Jump to content

[SOLVED] php not showing all options


lewis987

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/56866-solved-php-not-showing-all-options/
Share on other sites

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>

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)?

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.