[英]Php fetch data from multiple tables
I'm trying to fetch data from ring_desc table the column name is get_name here is my code: 我正在尝试从ring_desc表中获取数据,列名称为get_name,这是我的代码:
$query= mysqli_query($con, "SELECT * FROM LIST l, ring_desc r where l.user_id=$cook_val
and l.img_id=r.id");
while($row=mysqli_fetch_array($query)){
$name = $row['get_name'];
When I add $row['id']
which is column of List table it runs fine, but when I run this with get_name
it says: 当我添加
$row['id']
它是列表表的列)时,它运行良好,但是当我使用get_name
运行它时,它说:
Notice: Undefined variable: get_name
注意:未定义的变量:get_name
Try this, 尝试这个,
$query= mysqli_query($con, "SELECT l.*,r.* FROM LIST l, ring_desc r where l.user_id=$cook_val
and l.img_id=r.id");
试试这个查询:
SELECT l.*,r.* FROM LIST l inner join ring_desc r on l.img_id=r.id where l.user_id=$cook_val
mysqli_fetch_array-以数字数组的形式获取结果行,因此使用
$name = $row[3]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.