【发布时间】:2016-07-07 11:28:22
【问题描述】:
我想将我的代码从mysql 转换为mysqli。
但是,我这里有个问题。
mysql 代码是
for ($i = $start; $i < $end; $i++) {
// make sure that PHP doesn't try to show results that don't exist
if ($i == $total_results) {
break;
}
// echo out the contents of each row into a table
$bookid = mysql_result($result, $i, 'id');
$cover = mysql_result($result, $i, 'cover');
echo "
<div></div>
<li>
<div id='divborder'>
<div id='header'>
<a class='caption' href='page.php?id=$bookid '><img src='$cover' alt='' class='headerBg' /></a>
</div>
</div>
</li> ";
}
echo "</ul></div>";
我想把它转换成类似的东西
for ($i = $start; $i < $end; $i++) {
// make sure that PHP doesn't try to show results that don't exist
if ($i == $total_results) {
break;
}
$i;
$book_row = mysqli_fetch_assoc($result);
$book_id = $book_row["id"];
$book_cover = $book_row["cover"];
$book_title = $book_row["title"];
$book_auther1 = $book_row["auther1"];
$book_auther2 = $book_row["auther2"];
echo "
<div></div>
<li>
<div id='divborder'>
<div id='header'>
<a class='caption caption1'data-title='$data_title' href='book/$book_id'><img src='$book_cover' alt='' class='headerBg' /></a>
</div>
</div>
</li> ";
}
echo "</ul></div>";
但是mysql代码中变量$i的问题我不知道我会把它放在mysqli的哪个地方
【问题讨论】: