Jump to content

printing data into a table ?


Person

Recommended Posts

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

 

Link to comment
Share on other sites

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>";
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

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

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.