alka Posted October 24, 2009 Share Posted October 24, 2009 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 .. Quote Link to comment https://forums.phpfreaks.com/topic/178854-solved-multiple-mysql-queries-and-php-for/ Share on other sites More sharing options...
alka Posted October 25, 2009 Author Share Posted October 25, 2009 Solved by simply adding the mysql queries within the 'for' statement..... It was in the middle of the night when I realized it.. lol.. had been working too much the previous day I guess and did not see the obvious.. Quote Link to comment https://forums.phpfreaks.com/topic/178854-solved-multiple-mysql-queries-and-php-for/#findComment-944121 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.