使用PHP在搜索中显示查询中的多行数据 [英] Display multiple rows of data from a query in a search using PHP
问题描述
一个需要的菜鸟确实是一个菜鸟!我将不胜感激任何帮助!
所以我连接到我的数据库,
我在MySQL中有一个名为testable的表,看起来像这样:
testtable
number(int)________ customer(string)
1________________________bill
2________________________韩语
3________________________bill
4________________________hank
我想搜索hank并创建一个包含数字的数组[2,4]
我所能做的就是让它找到第一行,然后它创建一个数组,即[2,'hank']
我尝试了什么:
我尝试制作一个php脚本的mysqli查询像这样:
$ sql =select * from testtable where customer ='hank';
$ result = mysqli_query($ db,$ sql);
$ row = mysqli_fetch_array($ result,MYSQLI_NUM);
echo($ row [0]);
echo($ row [1]);
?>
但它只返回:
hank2
我希望它返回
24
任何想法?
sql =select * from testtable where customer ='hank';
< BLOCKQUOTE>结果= mysqli_query(
分贝,
a noob in need is a noob indeed! I would appreciate any help possible!
so I connect to my database,
I have a table named testable in MySQL that looks like this:
testtable
number(int) ________customer(string)
1________________________bill
2________________________hank
3________________________bill
4________________________hank
and I want to search for hank and make an array that contains the numbers [2,4]
All I can do is get it to find the first row and it makes an array that is [2,'hank']
What I have tried:
I tried making a php scripted mysqli query like this:
$sql="select*from testtable where customer='hank'";
$result=mysqli_query($db, $sql);
$row=mysqli_fetch_array($result, MYSQLI_NUM);
echo ($row[0]);
echo ($row[1]);
?>
but it only returns:
hank2
I want it to return
24
Any ideas?
sql="select*from testtable where customer='hank'";
result=mysqli_query(
db,
这篇关于使用PHP在搜索中显示查询中的多行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!