Jump to content

Recommended Posts

<div id=\"navbar\">
         Select A Category
        </div>
       <div id=\"items\">";
       $get_cats = mysql_query("SELECT * FROM tbl_category");
       while($cats = mysql_fetch_array($get_cats)){
       echo "<div id=\"category\" onclick=\"location.href=default.php?catid".$cats['cat_id'].";\"><b>".$cats['cat_name']."</b><br>
       <small>".$cats['cat_description']."</small></div></div></div></body></html>";
       }

 

Theres 5 categories in tbl_category,

 

but for some reason: (only one is showing up)

 

http://www.wmptest.com/clintormscart/default.php

 

hmmm..  any ideas?

Link to comment
https://forums.phpfreaks.com/topic/136090-only-getting-one-row/
Share on other sites

Actually all five are being displayed. It's your HTML that is causing the problem. The following highlighted code should be outside of your while loop:

<div id=\"navbar\">

        Select A Category

        </div>

      <div id=\"items\">";

      $get_cats = mysql_query("SELECT * FROM tbl_category");

      while($cats = mysql_fetch_array($get_cats)){

      echo "<div id=\"category\" onclick=\"location.href=default.php?catid".$cats['cat_id'].";\"><b>".$cats['cat_name']."</b><br>

      <small>".$cats['cat_description']."</small></div></div></div></body></html>";

      }

 

Fixed code:

 <div id=\"navbar\">
         Select A Category
        </div>
       <div id=\"items\">";

$get_cats = mysql_query("SELECT * FROM tbl_category");
while($cats = mysql_fetch_array($get_cats))
{
    echo "<div id=\"category\" onclick=\"location.href=default.php?catid".$cats['cat_id'].";\"><b>".$cats['cat_name']."</b><br>
             <small>".$cats['cat_description']."</small></div>\n";
}
echo "</div></div></body></html>";

Link to comment
https://forums.phpfreaks.com/topic/136090-only-getting-one-row/#findComment-709610
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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