0

在 PHP MYSQL_FETCH_ASSOC 中省略了 Last Row。这从未发生过。但这一次它让我在最后一刻陷入了困境。

即使我已经提出了 mysql_num_rows 结果是 14 条记录 - 但在列表中它只显示 13 条记录并且第 14 条记录被省略。

感谢任何形式的帮助。

                $uno = $_GET["uno"];

                $xtc1 = 'select * from rform where uno="' . $uno . '" order by rno DESC';
                $xtc = mysql_query($xtc1) or die('User Reservation Retrival Error : ' . mysql_error());

                $trno = mysql_fetch_assoc($xtc);
                $trow = mysql_num_rows($xtc);


                echo '<p>List of Onlilne Reservations made by <strong style="font-weight:bold; color:red;">' . ucwords($trno["cname"]) . ' (' . $trow . ')</strong></p>';

                echo '<table cellpadding="5" cellspacing="0" border="1">';
                    echo '<tr>';
                        echo '<td colspan="5" style=" font-size:14px; text-align:center; font-weight:bold; color:red;">' . ucwords($trno["cname"]) . '</td>';
                    echo '</tr>';
                    echo '<tr>';
                            echo '<th>R.NO</th>';
                            echo '<th>From</th>';
                            echo '<th>To</th>';
                            echo '<th>Date &amp; Time of<Br>Travel</th>';
                            echo '<th>Reserved On</th>';
                        echo '</tr>';   
                    while($mtn = mysql_fetch_assoc($xtc)){
                        $dt = $mtn["csdate"] . ' ' . $mtn["ctime"];
                        echo '<tr>';
                            echo '<td>' . $mtn["rno"] . '</td>';
                            echo '<td>' . $dt . '</td>';
                            echo '<td>' . $mtn["caddr"] . '</td>';
                            echo '<td>' . $mtn["cdest"] . '</td>';
                            echo '<td>' . date('d-M-Y',strtotime($mtn["tstamp"])) . '</td>';
                        echo '</tr>';   
                    }
                    echo '</table>';

4

2 回答 2

2

你有一个额外的东西$trno = mysql_fetch_assoc($xtc),你似乎要丢弃。这是您缺少的行。只需删除该行。

于 2013-01-03T01:20:34.970 回答
0

删除第一个$trno = mysql_fetch_assoc($xtc);将解决此问题。

如果您需要阅读$xtc循环之前的第一行。您可以将while循环更改为do-while,而无需删除第一个$mtn = mysql_fetch_assoc($xtc);

do{
    //whatever
}while($mtn = mysql_fetch_assoc($xtc));
于 2013-01-03T02:05:18.113 回答