這段代碼有什麼問題?當我點擊'下一步'按鈕時,它顯示空白頁面,並打破了我的網頁設計?我試圖弄清楚整天但沒有運氣。這個分頁有什麼問題?
<?php
if(isset($_GET['joke_id'])){
$joke_id = $_GET['joke_id'];
$qry = "SELECT * FROM joke WHERE joke_cat = '$joke_id'";
$result = mysqli_query($con, $qry) or die("Query failed: " . mysqli_errno($con));
$line = mysqli_fetch_array($result, MYSQL_BOTH);
if (!$line) echo '';
$previd = -1;
$currid = $line[0];
if (isset($_GET['id'])) {
$previous_ids = array();
do {
$previous_ids[] = $line[0];
$currid = $line[0];
if ($currid == $_GET['id']) break;
$previd = end($previous_ids);
$line = mysqli_fetch_array($result, MYSQL_BOTH);
} while ($line);
}
if ($line) {
echo "<div id=\"box\">";
echo nl2br($line['text']) . "<br /><br />";
echo "</div>";
}
else echo 'Is empty<br/>'; **<------ HERE**
if ($previd > -1)
echo '<a href="cat_vic.php?cat_id='.$joke_id.'?id='.$previd.'" class="prev_pic"><span>Prev</span></a>';
echo str_repeat(' ', 5);
$line = mysqli_fetch_array($result, MYSQL_BOTH);
$query = "select * from joke WHERE joke_cat = '$joke_id' order by RAND() LIMIT 1";
$result = mysqli_query($con, $query) or die("Query failed: " . mysqli_errno($con));
while ($row = mysqli_fetch_array($result, MYSQL_BOTH)){
echo '<a href="cat_vic.php?cat_id='.$joke_id.'?id='.$row['id'].'"class="random">Random</a>';
}
echo str_repeat(' ', 5);
if ($line) echo '<a href="cat_vic.php?cat_id='.$joke_id.'?id='.$line[0].'" class="next_pic"><span>Next</span></a><br /><br />';
echo "</div>\r";
}
?>
而且上線else echo 'Is empty<br/>';
如果有什麼沒關係..總是顯示我 '爲空' ..
UPDATE: 數據庫是: 笑話
id
text
date
joke_cat
和cat_joke
是
joke_id
joke_name
你用的var_dump($線)看,,,只是櫃面嘗試添加和開放如果條件爲 – Vishnu
var_dump($ line)返回空和破碎的頁面。 – user3346678