Jump to content

need help with query count + display


RCB

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

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.