用什么替换MySQLi的mysql_result [英] What to replace mysql_result with for MySQLi
本文介绍了用什么替换MySQLi的mysql_result的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
用mysql_result
替换什么?
function update_count() {
global $link;
$query = "SELECT `count`, FROM `hits_count`";
if($query_run = mysqli_query($link, $query)) {
$count = mysql_result($query_run, 0, 'count');
$count_inc = $count + 1;
echo $count;
}
}
update_count();
解决方案
mysqli_query
返回 mysqli_result
对象.从那里,您可以获取想要的价值.
if($query_run = mysqli_query($link, $query)) {
// This gets you one row at a time, use a while if there are multiple rows
// while($row = mysqli_fetch_assoc($query_run)){}
$row = mysqli_fetch_assoc($query_run);
$count = $row['count'];
// Do whatever with $count
}
what to replace mysql_result
with?
im watching a tutorial now but it was made in 2011 so it is not working now. Here is the situation, I will be very grateful if you tell me what to replace mysql_result with here, and what to put in the parenthesis
function update_count() {
global $link;
$query = "SELECT `count`, FROM `hits_count`";
if($query_run = mysqli_query($link, $query)) {
$count = mysql_result($query_run, 0, 'count');
$count_inc = $count + 1;
echo $count;
}
}
update_count();
解决方案
mysqli_query
returns you a mysqli_result
object. From there, you can get the value you want.
if($query_run = mysqli_query($link, $query)) {
// This gets you one row at a time, use a while if there are multiple rows
// while($row = mysqli_fetch_assoc($query_run)){}
$row = mysqli_fetch_assoc($query_run);
$count = $row['count'];
// Do whatever with $count
}
这篇关于用什么替换MySQLi的mysql_result的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文