PHP MYSQL脚本错误

时间:2012-10-16 10:50:28

标签: php mysql

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

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

我非常感谢你的支持!

1 个答案:

答案 0 :(得分:2)

$ID值为空,您必须在其中指定值。

其次,您正在检查$num>0其中$num的价值是多少?

从我的角度来看,你正试图获取行获取次数。