ctcp Posted December 1, 2011 Share Posted December 1, 2011 <?php $statisctis=("SELECT date_liked , COUNT(site_id) AS num_site_id FROM `liked` WHERE date_liked < CURDATE() AND date_liked > CURDATE() - INTERVAL 1 WEEK AND site_id='45' GROUP BY date_liked"); $result1 = mysql_query ($statisctis) or die(mysql_error()); ?> in php admin i get result like this date_liked num_site_id 2011-11-28 10:00:29 1 2011-11-29 05:03:17 1 2011-11-30 04:51:37 1 how to echo this in my page? Here i get a COUNT number only <?php $sum_datas = mysql_result($result1, 0); echo $sum_datas['date_liked']; ?> Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted December 1, 2011 Share Posted December 1, 2011 $statisctis = ("SELECT date_liked , COUNT(site_id) AS num_site_id FROM `liked` WHERE date_liked < CURDATE() AND date_liked > CURDATE() - INTERVAL 1 WEEK AND site_id='45' GROUP BY date_liked"); $result1 = mysql_query ($statisctis) or die(mysql_error()); echo "date_liked - num_site_id"; while($row = mysql_fetch_assoc($result1)) { echo $row['date_liked'] . " - " . $row['num_site_id']; } Quote Link to comment Share on other sites More sharing options...
ctcp Posted December 1, 2011 Author Share Posted December 1, 2011 Thank you my friend for replay now i got this promblem how can i loop percent fuction ? <?php $query="SELECT date_liked , COUNT(site_id) AS num_site_id FROM `liked` WHERE date_liked < CURDATE() AND date_liked > CURDATE() - INTERVAL 1 WEEK AND site_id='$id' GROUP BY date_liked"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ echo $row['date_liked']; echo "<br>"; echo $row['num_site_id']; echo "<br>"; $num_total = $data->coins; $num_amount =$row['num_site_id']; function percent1($num_amount, $num_total) { //<-- line 21 $count1 = $num_amount / $num_total; $count2 = $count1 * 100; $count = number_format($count2, 0); echo $count; } // end statistic last 7 days// } ?> Fatal error: Cannot redeclare percent1() (previously declared in line 21 Quote Link to comment Share on other sites More sharing options...
ctcp Posted December 1, 2011 Author Share Posted December 1, 2011 <?php $query="SELECT date_liked , COUNT(site_id) AS num_site_id FROM `liked` WHERE date_liked < CURDATE() AND date_liked > CURDATE() - INTERVAL 1 WEEK AND site_id='$id' GROUP BY date_liked"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ echo $row['date_liked']; echo "<br>"; echo $row['num_site_id']; echo "<br>"; $p = $data->coins; $num_amount =$row['num_site_id']; echo ($num_amount/$p*100) . "% of rows selected."; } // end statistic last 7 days// ?> Quote Link to comment 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.