Jump to content

[SOLVED] Multiple MYSQL queries and php for..


Recommended Posts

Hi...

 

While still in the leaning process of PHP and MySQL I've started working on something

specific.. I just tend to learn faster that way...

 

What I'm trying to do a create a basic tacker.. its more or less useful already.. I have a hard

time displaying some stats in the view mode described below.

 

So here is my problem..

 

I currently list all trackers with the current code:

 

First fetch data from mysql:

$query = mysql_query("SELECT * FROM trackers WHERE uid='$uid'");

 

Then some PHP to display it:

 for ($i = 0; $i < mysql_num_rows($query); $i++) {

        $sid = mysql_result($query, $i, "id");
        $sname = mysql_result($query,$i, "name");

        $surl = mysql_result($query, $i, "url");

echo "$sid | $sname | $surl |");

 

That works fine, shows all the trackers id, name and url that I'm tracking...

I however want to add RAW hits and Unique hits for each url as well.. and I'm clueless

to where I add the code.. I'm able to display it for one url at a time, but not using a array displaying all

urls using the PHP 'for'

 

The raw and unique should be total for all time (as much data available in mysql) and for the past 24 hours.

 

The mysql queries I use to display for a single selected tracker is:

 

$query = mysql_query("SELECT id, tid, INET_NTOA(rip) as rip, curl, datetime FROM tracked_data WHERE tid='$ttid'");
$query2 = mysql_query("SELECT DISTINCT rip FROM tracked_data WHERE tid='$ttid'");

$days_1 = mysql_num_rows(mysql_query("SELECT * FROM tracked_data WHERE datetime BETWEEN DATE_SUB(NOW(), interval 24 HOUR) AND NOW() AND tid='$ttid'"));
$days_1unique = mysql_num_rows(mysql_query("SELECT DISTINCT rip FROM tracked_data WHERE datetime BETWEEN DATE_SUB(NOW(), interval 24 HOUR) AND NOW() AND tid='$ttid'"));

 

The above code works for specific trackers like mentioned on a separate php file.. :)..

 

Please advice :)..

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.