Person Posted May 24, 2007 Share Posted May 24, 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' . ' user,' . ' sum(imps) AS imps,' . ' sum(clicks) AS clicks,' . ' sum(clientrev) AS clientrev' . ' FROM' . ' nuke_pnAffiliate_unauditedstats' . ' WHERE' . ' `date` = ' . $yesterday . ' AND ' . ' sid like \'%rpu%\' AND user IN (SELECT DISTINCT(cl) FROM rpu_sales WHERE salesman = \'ryan\')' . ' GROUP BY user' . ' ORDER BY clientrev DESC '; $result = mysql_query($query); $num_results = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)){ echo $row['user'] . $row['imps'] . $row['clicks'] . $row['clientrev'].'<br>'; } ?> how would i print those figures into a table? this is how it prints : eflouret2589211629.2400002479553 mmblogpire909410526.4599993228912 uniquelink51337716.9799995422363 fosfor5327408.81999969482422 Darla3730316.84000015258789 jennklee1871295.48000001907349 stanzapub5435295.4799998998642 affiliate26006007215.28999996185303 anthroa25247244.52999997138977 iepurilah69582.01999998092651 lancelhoff7186101.88999998569489 10zenmonkeys420471.32000005245209 wildbluffmedia1198861.12999999523163 garrigus34651.09999999403954 emom73410.189999997615814 vwizard300 geeksaresexy636800 netceo1400 maloosh300 capablenetworks101900 mynetwork248800 qweszx200 Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/ Share on other sites More sharing options...
MadTechie Posted May 24, 2007 Share Posted May 24, 2007 Just create a table.. (HTML) and use the etc as entrys ie <?php echo "<table width='200' >"; while ($row = mysql_fetch_assoc($result)) { echo " <tr>"; echo " <td>{$row['user']}</td>"; echo " <td>$row['imps']</td>"; echo " </tr>"; } echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260809 Share on other sites More sharing options...
Fearpig Posted May 24, 2007 Share Posted May 24, 2007 You just have to put in the HTML tags for building a table and have your PHP script echo them in the right place..... <table><tr><th>User</th><th>Imps</th><th>Clicks</th><th>ClientRev</th></tr> <?php while(your conditions){ echo "<tr><td>Field 1</td><td>Field 2</td><td>Field 3</td><td>Field 4</td></tr>"; } ?> </table> Look into basic html design if you need anything more complicated (colours, background images, spanning columns). Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260815 Share on other sites More sharing options...
colombian Posted May 24, 2007 Share Posted May 24, 2007 PHP can integrate without issues to HTML (it's made that way). So you just need to echo the HTML to make the table as you output your results. After your while loop: <?PHP echo "<table>"; echo "<tr><td>".$row['user'] ."</td><td>". $row['imps'] ."</td><td>". $row['clicks'] ."</td><td>". $row['clientrev']."</td></tr>"; echo "</table>"; ?> I haven't checked the syntax, but that's pretty much it. Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260818 Share on other sites More sharing options...
Person Posted May 24, 2007 Author Share Posted May 24, 2007 sorry Deleted mgs Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260830 Share on other sites More sharing options...
MadTechie Posted May 24, 2007 Share Posted May 24, 2007 i don't see the problem ?! what you trying ? Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260833 Share on other sites More sharing options...
Person Posted May 24, 2007 Author Share Posted May 24, 2007 $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' . ' user,' . ' sum(imps) AS imps,' . ' sum(clicks) AS clicks,' . ' sum(clientrev) AS clientrev' . ' FROM' . ' nuke_pnAffiliate_unauditedstats' . ' WHERE' . ' `date` = ' . $yesterday . ' AND ' . ' sid like \'%rpu%\' AND user IN (SELECT DISTINCT(cl) FROM rpu_sales WHERE salesman = \'ryan\')' . ' GROUP BY user' . ' ORDER BY clientrev DESC '; $result = mysql_query($query); $num_results = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { echo "<table>"; echo "<tr><td>".$row['user'] ."</td><td>". $row['imps'] ."</td><td>". $row['clicks'] ."</td><td>". $row['clientrev']."</td></tr>"; echo "</table>"; } $email_to = ""; $email_from = "MAil Server Total Clicks"; $email_subject = "I dont know that to name the other tables ?."; $email_body = "Content-Type: text/html; charset=UTF-8\n"; $email_body .= "Content-Transfer-Encoding: 8bit\n\n"; $email_body .= "<table>"; "<tr><td>".$row['user'] ."</td><td>". $row['imps'] ."</td><td>". $row['clicks'] ."</td><td>". $row['clientrev']."</td></tr>"; "</table>"; mail($email_to,$email_from,$email_subject,$email_body,"From:$email_from\are\nReply-To:do not reply to sever"); ?> Code works all the way up to the E-mail. Now i want to print the table in the E-mail.... how do i go about doing that without it giving me errors. As it is now its not printing the data in the E-mail. Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260846 Share on other sites More sharing options...
MadTechie Posted May 24, 2007 Share Posted May 24, 2007 you want to email as HTML.. you could look at phpmailer.. whats the email look like ? plain text ? Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260857 Share on other sites More sharing options...
Person Posted May 24, 2007 Author Share Posted May 24, 2007 I would want something that looks nice, and has a nice table thats easy to read. Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260863 Share on other sites More sharing options...
MadTechie Posted May 24, 2007 Share Posted May 24, 2007 and what you getting at the moment ? is the email formatting as HTML or planText? plain text being <table width="200" > <tr> <td>Name:</td> <td>MadTechie</td> </tr> </table> etc Quote Link to comment https://forums.phpfreaks.com/topic/52830-printing-data-into-a-table/#findComment-260867 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.