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