Jump to content

help with outputting data.


want2php

Recommended Posts

hi,

 

i have two tables:

A.status (values below)

  stat      statdef

  1          online

  2          offline

  3          live

 

B. log (values below)

  logid  stat(get its data from A)  time_date(timestamp)

    1          1                               

    2          1

    3          2

    4          1    .... and so on.

 

What i want to achieve is to query the first table as a reference and then check and count table B for matching stat.  I am a newbie to this and already spent hours but couldn't get the right result.

 

here's my code:

$sql = "select stat from status"

while ($result = mysql_fetch_array) {
     $statsql = "select count(id) from log where stat = $result"
     $countstat = mysql_fetch_array($statsql);
}

echo ' Total number count';
echo 'online' . $countstat;
echo 'offline' . $countstat;
echo 'live' . $countstat;

Link to comment
https://forums.phpfreaks.com/topic/180244-help-with-outputting-data/
Share on other sites

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.