Person Posted May 23, 2007 Share Posted May 23, 2007 <?php $host = ""; $user = ""; $pass = ""; $dbname = ""; $con = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); $yesterday = date('20ymd', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y"))); $query= "SELECT SUM(1) AS clicks, SUM(`clcpc`), SUM(`chcpc`) FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND `date` = '" . $yesterday . "'"; $result= mysql_query($query); $row= mysql_fetch_assoc($result); echo $result ; ?> should print : clicks SUM(`clcpc`) SUM(`chcpc`) 211 38.299999821931 84.569998212159 but it prints : Resource id #5 How do i fix this ? Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/ Share on other sites More sharing options...
trq Posted May 23, 2007 Share Posted May 23, 2007 You need to print the $row array, not $result. mysql_query returns a result resource. Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-259950 Share on other sites More sharing options...
Person Posted May 23, 2007 Author Share Posted May 23, 2007 so how do i go about printing that ? would i just echo $row ? Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-259967 Share on other sites More sharing options...
taith Posted May 23, 2007 Share Posted May 23, 2007 echo $row[clicks].$row[]...... Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-259969 Share on other sites More sharing options...
Person Posted May 23, 2007 Author Share Posted May 23, 2007 its only printing clicks.... ? echo $row[clicks].$row[chcpc].$row[clcpc] ; Anyone know how it prints it in the Mysql admin ? Thats how i want it to print with the tables, but im new to this and have no idea how to do that... Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-259976 Share on other sites More sharing options...
taith Posted May 23, 2007 Share Posted May 23, 2007 because on your query, your not renaming the columns to chcpc... you need to either use $row['SUM(chcpc)']; or add to your query sum() "as chcpc" Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-259981 Share on other sites More sharing options...
kenrbnsn Posted May 23, 2007 Share Posted May 23, 2007 Change <?php $query= "SELECT SUM(1) AS clicks, SUM(`clcpc`), SUM(`chcpc`) FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND `date` = '" . $yesterday . "'"; $result= mysql_query($query); $row= mysql_fetch_assoc($result); echo $result ; ?> to <?php $query= "SELECT SUM(1) AS clicks, SUM(`clcpc`) as clcpc, SUM(`chcpc`) as chcpc FROM `nuke_pnAffiliate_clicktracking` WHERE `pl` = 'rpu' AND `date` = '" . $yesterday . "'"; $result= mysql_query($query); $row= mysql_fetch_assoc($result); printf("%d %02.12f %02.12f",$row['clicks'],$row['clcpc'],$row['chcpc']); ?> Ken Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-259983 Share on other sites More sharing options...
Person Posted May 23, 2007 Author Share Posted May 23, 2007 Ok now that, that problem is fixed .... is there a way i can put a table round it ? Like in the mysql admin ? Is there some type of php code to do this ? or would i have to make the table the manual way ? Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-259985 Share on other sites More sharing options...
taith Posted May 23, 2007 Share Posted May 23, 2007 echo '<table><tr><td>'.$yourvarshere.'</td></tr></table>'; Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-259993 Share on other sites More sharing options...
Person Posted May 23, 2007 Author Share Posted May 23, 2007 so there is no way i can build the table around the data ? so if there is more data there is more parts of the table to populate ? Link to comment https://forums.phpfreaks.com/topic/52657-echo-error-not-printing-the-data-i-want/#findComment-260083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.