我想通过id到第二页,我从另一个表中选择,但下面的代码不工作。当我做var_dump时,我可以看到值是我想要的,但主查询的行不显示(标题和图像未显示)。通过URL传递id到第二页
我有两个查询,其中一个是在另一个里面。有人可以帮我吗?主要查询工作正常,如果我摆脱第二个查询的while loop
。
$paginate = new pagination($page, "SELECT * FROM table1 where title != '' ORDER BY id desc" , $options);
}
}
catch(paginationException $e)
{
echo $e;
exit();
}
if($paginate->success == true)
{
$result = $paginate->resultset->fetchAll();
foreach($result as $row)
{
$dx = $row['image_one'];//image_one from main query
//second query
$item = $mydb->prepare("select * from table2 where imageone = ?");
$item->bind_param('s', $dx);
$item->execute();
$item_res = $item->get_result();
while($row = $item_res->fetch_assoc()){
$rx = $row['id'];
var_dump($rx);
} //the rows below aren't being displayed
$path = 'images/';
echo "<a href='second.php?title=".urlencode($row['title'])." &item=".$row['id']."&id=".$rx."'>"."<img src='".$path."".$row['image_one']."'/></div>"."</a>";
}
感谢这个作品。 – user3006683