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