我一直在努力解决这个问题,但我做不到。
$sqluser = "--";
$sqlpass = "--";
$hostname = "localhost";
$clientuser = $_COOKIE['user'];
//connection to the database
$dbhandle = mysql_connect($hostname, $sqluser, $sqlpass)
or die("Unable to connect to MySQL");
//select a database to work with
$selected = mysql_select_db("clhtechn_si1",$dbhandle)
or die("Could not select database!");
//execute the SQL query
$idfinder = mysql_query("SELECT id FROM `si_customers` WHERE username='$clientuser'") or die(mysql_error());
$clientid = mysql_fetch_assoc($idfinder);
$query = "SELECT invoice_id, date, SUM(total) as invoiceTotal
FROM si_invoices
LEFT JOIN si_invoice_items ON si_invoices.id = si_invoice_items.invoice_id
WHERE si_invoices.customer_id='$clientid'
GROUP BY invoice_id
ORDER BY invoice_id";
$result = mysql_query($query);
$row=0;
while ($record = mysql_fetch_assoc($result))
{
$class = 'd' . ($row % 2);
$inv_date=substr($record['date'], 0, -9);
$inv_total=$record['invoiceTotal'];
$invoice_total=number_format($inv_total, 2);
echo "<tr class=\"{$class}\">";
echo "<td valign='top'>{$inv_date}</td>";
echo "<td valign='top'>{$record['invoice_id']}</td>";
echo "<td valign='top'>$invoice_total</td>";
echo "<td><a href='invoices/Invoice_{$record['invoice_id']}.pdf' target='_blank'>";
echo "<img src='urlhere' width='17' height='17' alt='PDF File' border='0' /></a></td>";
echo "</tr>";
$row++;
}
//close the connection
mysql_close($dbhandle);
这是我的客户表的对齐方式: 链接到图片。
我的代码有什么问题,我可以使用什么代码来修复它?帮助表示赞赏。