Output date in html problem
Posted: Thu Mar 20, 2008 6:16 am
Hello, I have a problem retrieving and show data from a database. I have the following query:
$host1="localhost"; // Host name
$username1="user"; // Mysql username
$password1="********"; // Mysql password
$db_name1="dbname"; // Database name
$link1 = mysql_connect($host1, $user1, $password1) or die("I can't connect!");
$tabela = mysql_select_db($db_name1, $link1) or die("I can't select table!");
$query="SELECT ";
$query.='trafficSummaries.sitesID AS sitesID';
$query.=',';
$query.='sites.site AS site';
$query.=',';
$query.='SUM(trafficSummaries.inCache+trafficSummaries.outCache) AS bytes';
$query.=',';
$query.='TRUNCATE((SUM(trafficSummaries.inCache)/SUM(trafficSummaries.inCache+trafficSummaries.outCache))*100,0) AS cachePercent';
$query.=' FROM trafficSummaries';
$query.=' JOIN sites ON ';
$query.='trafficSummaries.sitesID=sites.id';
$query.=' AND ';
$query.='trafficSummaries.date=sites.date';
$query.=' WHERE ';
$query.="trafficSummaries.ip='".$pageVars['hostiplong']."'";
$query.=" AND";
$query.=" trafficSummaries.date='".$pageVars['date']."'";
$query.=" GROUP BY trafficSummaries.sitesID";
$query.=' ORDER BY '.$pageVars['OrderBy'].' '.$pageVars['OrderMethod'];
$resultIP = mysql_query($query, $link1);
Here I try to get the objects from the tables:
echo "<center>
<table>
<tr>
<th></th>
<th>SITE</th>
<th width=110>Traffic</th>
</tr>";
while ($row = mysql_fetch_object($$resultIP)) {
echo "<tr onMouseOver=bgColor=#C5D3E7; onMouseOut=bgColor=#DAE3F0>
<td style=text-align: center;>$row->site</td>
<td style=text-align: left;>$row->bytes[/url]</td>
<td></td>
</tr>";
}
echo "<tr>
<th>TOTALS</th>
<th style=text-align: right;></th>
<th style=text-align: right;></th>
</tr>
</table>
</center>";
This is the first time I using such query to get informations from more tables. I used the output of of the $query into mysql and I get the informations, but when I try from php I get no error. Can anyone give me an idea?
Thank you!
$host1="localhost"; // Host name
$username1="user"; // Mysql username
$password1="********"; // Mysql password
$db_name1="dbname"; // Database name
$link1 = mysql_connect($host1, $user1, $password1) or die("I can't connect!");
$tabela = mysql_select_db($db_name1, $link1) or die("I can't select table!");
$query="SELECT ";
$query.='trafficSummaries.sitesID AS sitesID';
$query.=',';
$query.='sites.site AS site';
$query.=',';
$query.='SUM(trafficSummaries.inCache+trafficSummaries.outCache) AS bytes';
$query.=',';
$query.='TRUNCATE((SUM(trafficSummaries.inCache)/SUM(trafficSummaries.inCache+trafficSummaries.outCache))*100,0) AS cachePercent';
$query.=' FROM trafficSummaries';
$query.=' JOIN sites ON ';
$query.='trafficSummaries.sitesID=sites.id';
$query.=' AND ';
$query.='trafficSummaries.date=sites.date';
$query.=' WHERE ';
$query.="trafficSummaries.ip='".$pageVars['hostiplong']."'";
$query.=" AND";
$query.=" trafficSummaries.date='".$pageVars['date']."'";
$query.=" GROUP BY trafficSummaries.sitesID";
$query.=' ORDER BY '.$pageVars['OrderBy'].' '.$pageVars['OrderMethod'];
$resultIP = mysql_query($query, $link1);
Here I try to get the objects from the tables:
echo "<center>
<table>
<tr>
<th></th>
<th>SITE</th>
<th width=110>Traffic</th>
</tr>";
while ($row = mysql_fetch_object($$resultIP)) {
echo "<tr onMouseOver=bgColor=#C5D3E7; onMouseOut=bgColor=#DAE3F0>
<td style=text-align: center;>$row->site</td>
<td style=text-align: left;>$row->bytes[/url]</td>
<td></td>
</tr>";
}
echo "<tr>
<th>TOTALS</th>
<th style=text-align: right;></th>
<th style=text-align: right;></th>
</tr>
</table>
</center>";
This is the first time I using such query to get informations from more tables. I used the output of of the $query into mysql and I get the informations, but when I try from php I get no error. Can anyone give me an idea?
Thank you!