Php Convert$note1=mysql_result($result,0,“note_content”);与mysqli等效

Php Convert$note1=mysql_result($result,0,“note_content”);与mysqli等效,php,mysql,mysqli,Php,Mysql,Mysqli,我有以下运行良好的旧PHP代码: <?php $query = "SELECT * FROM notes WHERE note_name='Test Note'"; $result = mysql_query($query); $note1 = mysql_result($result, 0, "note_content"); $note2 = mysql_result($result, 1, "note_content"); echo "<p>$note1</p&g

我有以下运行良好的旧PHP代码:

<?php
$query = "SELECT * FROM notes WHERE note_name='Test Note'";
$result = mysql_query($query);

$note1 = mysql_result($result, 0, "note_content");
$note2 = mysql_result($result, 1, "note_content");

echo "<p>$note1</p>
<p>$note2</p>"
?>
如果安装了驱动程序,可以执行以下操作:

$all_rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
$note1 = $all_rows[0]["note_content"];
$note2 = $all_rows[1]["note_content"];
如果没有,则必须分别获取每一行:

$row = mysqli_fetch_assoc($result);
$note1 = $row["note_content"];
$row = mysqli_fetch_assoc($result);
$note2 = $row["note_content"];

此处缺少链接参数
$result=mysqli\u query($query)
@ShankarDamodaran我添加了link参数,但这不是问题所在。
不起作用
不是很具体。您可以这样使用函数mysqli_result($res,$row,$field=0){$res->data_seek($row);$datarow=$res->fetch_array();return$datarow[$field];}@srbhattarai与重复问题中的一个答案不是很相似吗?我指定的函数使代码保持干燥
$row = mysqli_fetch_assoc($result);
$note1 = $row["note_content"];
$row = mysqli_fetch_assoc($result);
$note2 = $row["note_content"];