Jump to content

php echo help


ctcp

Recommended Posts

<?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'];
?>

Link to comment
https://forums.phpfreaks.com/topic/252207-php-echo-help/
Share on other sites

$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'];
}

Link to comment
https://forums.phpfreaks.com/topic/252207-php-echo-help/#findComment-1293005
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/252207-php-echo-help/#findComment-1293007
Share on other sites

<?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//
?>

Link to comment
https://forums.phpfreaks.com/topic/252207-php-echo-help/#findComment-1293012
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.