-3
我的客戶端使用的是PHP 5.2.0版,我有一些完美的代碼,但目前使用5.4.7。當我的代碼在他們的服務器上運行時,我收到一個解析錯誤。我在網上搜索了一種替代方法來編寫這段代碼,但我找不到任何東西。如果任何人有任何提示,這將是一個很大的幫助。PHP版本 - 較低版本的難度編碼
**$count = mysqli_query($con, "SELECT COUNT(*) FROM menuitem")->fetch_row()[0];** //I want to make sure the previous and next button are only displayed exactly to the number of items
//in my database. I have to count those items, and turn that mysqli_query object into data. fetch_row[0] stores them
//in an array, starting at 0, turning it into an integer I can use to count below.
$prev = $start - 3;
if ($prev >= 0) {
echo '<td><a href="?start=' . $prev . '">Previous Items</a></td>';// Set your $start - 3 since our offset is 3, and pass that to a variable.
} //if $start - 3 is still greater than 0, then display the previous button. Logically, that is page 2.
$next = $start + 3;
if ($next < $count) {
echo '<td><a href="?start=' . $next . '">Next Items</a></td>';// Since i used fetch_row[0] I now know how many rows I have. If $start + 3 is less than the $count query
} // than you will have a next button. If that number exceeds the number of rows I have, then no next button.
echo "</tr>";
echo "</table>";
在上面的代碼中,...-> fetch_row()[0];是帶回錯誤的部分。 PHP 5.2.0不喜歡它。
我很確定「PHP 5.2.0不喜歡它」。不是錯誤消息。始終分享確切的錯誤消息。 – PeeHaa