Jump to content

Recommended Posts

hey guys im trying to make a query that will display  certain elements from the  rows in the table and count the # rows

 

i think it might be my foreach statement  its seems to be displaying for each column instead of each row in the table...

 

here is my current code... please keep in mind that my php knowledge is very limited

 

           $ipbwi->DB->allow_sub_select=1;

       $result = $ipbwi->DB->query("

          SELECT *
          FROM ibf_arcade_sessions s
          LIMIT 5
       ");


            $online = ($r = $ipbwi->DB->fetch_row($result));
            $count = "0";


if(is_array($online) && count($online) > 0){
        foreach ($online as $i) {

              $sys .= ''.$r['mid'].'testing,<br />';
              ++$count;


        }
}


   ?>
      #  <?php echo $count ?>   <br /> user     <?php echo $sys ?>

 

thanks for the help

cheers

 

Link to comment
https://forums.phpfreaks.com/topic/147419-need-help-with-query-count-display/
Share on other sites

You'll want to use something more like:

 

$result = $ipbwi->DB->query("
    SELECT *
    FROM ibf_arcade_sessions s
    LIMIT 5
");

$i = 1;
while ($r = $ipbwi->DB->fetch_row($result)) {
    echo '#' . $i . '<br />' . $r['mid'] . '<br />';
}

 

Adam

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.