我正在尝试创建一个计费历史记录页面,用户可以在其中看到一个表格,其中包含表格格式的购买历史记录。我正在尝试为每一行添加一个链接,以便用户可以查看每个订单的完整发票详细信息。
当他们点击链接时(我在这个脚本之后包含了概述页面的脚本)这个脚本应该执行查询,但我只是得到一个空的消息查询。
任何人都可以发现错误吗?
谢谢!!
尤金妮
<?php
include("mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
$host="localhost"; // Host name
$username="user"; // Mysql username
$password="pass"; // Mysql password
$db_name="db"; // Database name
$tbl_name="table"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// get value of id that sent from address bar
$TicketID=$_GET['TicketID'];
// Retrieve data from database
$sql="SELECT * FROM $tbl_name WHERE TicketID='$TicketID'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
// Get a specific result from the "example" table
$result = mysql_query($Sql) or die(mysql_error());
echo "<table width='100' border='1' cellpadding='0' cellspacing='0' id='records'>";
print "<h3 align='center'><strong>Billing History</strong></h3><p>";
echo "<tr>
<th width='110' align='center'>Billing Date</th>
<th width='80' align='center'>Ticket #</th>
<th align='center'>Project Title </th>
<th width='80' align='center'>Total GBP</th>
</tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr height='22' width='100' bordercolor='343434' align='center'><td>";
echo $row['date'];
echo "</td><td> ";
echo $row['TicketID'];
echo "</td><td> ";
echo $row['project'];
echo "</td><td> ";
echo $row['grandTotal'];
}
echo "</table>";
include(XOOPS_ROOT_PATH."/footer.php");
?>
这是显示完整计费历史记录的脚本,其中包含与执行查询的脚本的链接(上图)。
<?php
include("mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
$host="localhost"; // Host name
$username="username"; // Mysql username
$password="password"; // Mysql password
$db_name="db name"; // Database name
$tbl_name="tbl name"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name WHERE uid='";
$sql=$sql . $xoopsUser->uid("s") . "' AND Paid='Y'";
$result=mysql_query($sql);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from mysql </strong> </td>
</tr>
<tr>
<td align="center"><strong>Billing Date</strong></td>
<td align="center"><strong>Invoice Number</strong></td>
<td align="center"><strong>Description</strong></td>
<td align="center"><strong>Total GBP</strong></td>
<td align="center"><strong>View</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['date']; ?></td>
<td><? echo $rows['TicketID']; ?></td>
<td><? echo $rows['project']; ?></td>
<td><? echo $rows['grandTotal']; ?></td>
<td align="center"><a href="http://website.co.uk/site/viewInvoice.php?TicketID=<? echo $rows['TicketID']; ?>">View</a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<?php
mysql_close();
include(XOOPS_ROOT_PATH."/footer.php");
?>