0

请帮忙找出一个错误:结果是查询为空!我不知道问题可能出在哪里,实际上我知道mysql_query可能有问题:

<?php
include("connect.php");
?>
<?php
$result = mysql_query("SELECT PEOPLE.ID AS ID, 
                            PEOPLE.NAME AS NAME, 
                            TICKETS.TICKETID AS TICKET_NO, 
                            RECEIPTS.DATENEW AS TICKET_DATE, 
                            PAYMENTS.TOTAL AS MONEY, 
                            CUSTOMERS.NAME AS CUSTOMER, 
                            PAYMENTS.PAYMENT AS PAYMENT
        FROM PEOPLE, RECEIPTS 
        INNER JOIN TICKETS ON RECEIPTS.ID = TICKETS.ID 
        INNER JOIN PAYMENTS ON RECEIPTS.ID = PAYMENTS.RECEIPT
        INNER JOIN CUSTOMERS ON TICKETS.CUSTOMER = CUSTOMERS.ID
        WHERE TICKETS.PERSON = '.$ID.'");
if ($num > 0 ) {
$i=0;
while ($i < $num) {
        $ID = stripslashes(mysql_result($result,$i,"ID"));
        $ID = stripslashes(mysql_result($result,$i,"ID"));
        $NAME = stripslashes(mysql_result($result,$i,"NAME"));
        $TICKET_NO = stripslashes(mysql_result($result,$i,"TICKET_NO"));
        $TICKET_DATE = stripslashes(mysql_result($result,$i,"TICKET_DATE"));
        $MONEY = stripslashes(mysql_result($result,$i,"MONEY"));
        $CUSTOMER = stripslashes(mysql_result($result,$i,"CUSTOMER"));
        $PAYMENT = stripslashes(mysql_result($result,$i,"PAYMENT"));

    $row .= '<tr>
    <td><a href="update.php?ID='.$ID.'">'.$ID.'</a></td>
    <td><a href="update.php?NAME='.$NAME.'">'.$NAME.'</a></td>
    <td><a href="update.php?TICKET_NO='.$TICKET_NO.'">'.$TICKET_NO.'</a></td>
    <td><a href="update.php?TICKET_DATE='.$TICKET_DATE.'">'.$TICKET_DATE.'</a></td>
    <td><a href="update.php?MONEY='.$MONEY.'">'.$MONEY.'</a></td>
    <td><a href="update.php?CUSTOMER='.$CUSTOMER.'">'.$CUSTOMER.'</a></td>
    <td><a href="update.php?PAYMENT='.$PAYMENT.'">'.$PAYMENT.'</a></td>
    <td><a href="delete.php?ID='.$ID.'">Delete</a></td>
    </tr>';

++$i; }} else { $row = '<tr><td colspan="2" align="center">Nothing found</td></tr>'; 
}

mysql_close();
?>
<table border="1" cellpadding="3" cellspacing="0"><? echo $row ?></table>

我非常感谢您的支持!

4

1 回答 1

2

$IDvalue 为空,您必须在其中分配 value。

其次,您正在检查$num>0where 但 value 是$num什么?

从我的角度来看,您正在尝试获取获取的行数。

于 2012-10-16T10:55:32.380 回答