相呼应的mysqli查询 [英] Echoing mysqli queries
本文介绍了相呼应的mysqli查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我想呼应从mysqli的查询中选择2 COLS但它看起来像我做错了什么。
Hi i'm trying to echo 2 cols selected from a mysqli query but it looks like i'm doing something wrong.
require('db_access.php');
$result = mysqli_query($db_connection, "SELECT id, intestatario FROM fatture_intestatari");
mysqli_close($db_connection);
$c = mysqli_num_rows($result);
if ($c == 0){ echo "Address book is empty";}
else {
while($row = mysqli_fetch_array($result)){
echo "<a href='#' onClick='get_holder_info('".$result['id']."');'>".$result['intestatario']."</a><br />";
};
};
使用此我得到一个致命错误:无法使用类型mysqli_result的对象数组
如果我使用不见了
Using this i get a "Fatal error: Cannot use object of type mysqli_result as array" That is gone if i use
require('db_access.php');
$result = mysqli_query($db_connection, "SELECT id, intestatario FROM fatture_intestatari");
mysqli_close($db_connection);
$c = mysqli_num_rows($result);
if ($c == 0){ echo "Address book is empty";}
else {
while($row = mysqli_fetch_array($result)){
echo "<a href='#' onClick='get_holder_info('".$result->id."');'>".$result->intestatario."</a><br />";
};
};
但仍然没有像它应该呼应了COLS所有的值。
有什么建议么?
谢谢
but still it doesn't echo all the values in the cols like it should. Any suggestions? Thanks
推荐答案
使用 $行
, $结果
只是一个 mysqli_result
对象:
while($row = mysqli_fetch_array($result)){
echo "<a href='#' onClick='get_holder_info('".$row['id']."');'>".$row['intestatario']."</a><br />";
这篇关于相呼应的mysqli查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文