gpt4 book ai didi

php - 通过从具有公共(public)列的两个表中选择数据来未定义索引

转载 作者:行者123 更新时间:2023-11-29 10:08:38 24 4
gpt4 key购买 nike

我有两个表 - homepostshome.artid 等于posts.id

想要从 home 中选择 id、artid、inde 以及从 posts 中选择 title
其中 home.posslider:

$items = "";
$st = $db->query("select home.id, home.artid, home.inde
from home
join posts on home.artid = posts.id
where home.pos = 'slider'
order by home.inde asc");
while ($row = $st->fetch()){
$items .= "<div class='slidertitle'>" . $row['posts.title'] . "</div>\n";
}
echo $items;

错误:
未定义索引 posts.title...

有什么帮助吗?

最佳答案

如果您想选择posts.title,请选择它

$st = $db->query("select home.id, home.artid, home.inde, 
posts.title
from home
join posts on home.artid = posts.id
where home.pos = 'slider'
order by home.inde asc");

// and it would be called just `title`

while ($row = $st->fetch()){
$items .= "<div class='slidertitle'>" . $row['title'] . "</div>\n";
}
echo $items;

关于php - 通过从具有公共(public)列的两个表中选择数据来未定义索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51411781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com