Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Mysql_fetch_assoc忽略了最后一行_Php - Fatal编程技术网

PHP Mysql_fetch_assoc忽略了最后一行

PHP Mysql_fetch_assoc忽略了最后一行,php,Php,在PHP中,MYSQL_FETCH_ASSOC省略了最后一行。这从未发生过。但这一次,在最后一刻,它让我陷入了困境 即使我已经设置了mysql_num_行,结果是14条记录——但在列表中它只显示了13条记录,而第14条记录被省略了 感谢您的任何帮助 $uno = $_GET["uno"]; $xtc1 = 'select * from rform where uno="' . $uno . '" order by rno DESC

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

即使我已经设置了mysql_num_行,结果是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>';
您有一个额外的$trno=mysql\u fetch\u assoc$xtc要丢弃。这是你缺的那一排。只需删除该行。

删除第一个$trno=mysql\u fetch\u assoc$xtc;这将解决这个问题

以防需要在循环之前读取$xtc的第一行。您可以将while循环更改为do while,而不删除第一个$mtn=mysql\u fetch\u assoc$xtc


就这样,谢谢你,科林克
do{
    //whatever
}while($mtn = mysql_fetch_assoc($xtc));