RCB Posted March 1, 2009 Share Posted March 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147419-need-help-with-query-count-display/ Share on other sites More sharing options...
Adam Posted March 1, 2009 Share Posted March 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147419-need-help-with-query-count-display/#findComment-773794 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.