【发布时间】:2017-09-19 12:25:47
【问题描述】:
我正在尝试从数据库中获取一些值,但是 while/foreach 不起作用。
<?php
$type_id = $article->type_id;
$sql = " SELECT * FROM `interior_image_testing` WHERE `type_id` = '$type_id' ";
//echo $sql;
//$result = mysqli_query($con,$sql);
if ($result = mysqli_query($con, $sql)) {
//echo $result;
$obj = mysqli_fetch_array($result);
foreach ($obj as $objs):
?>
<div class="col-lg-4 col-md-4 col-sm-4 col-6 workimg">
<img src="assets/img/<?php echo $objs['image_path']; ?> " width="100%"> <!-- needs to be changed -->
</div>
<?php
endforeach;
}
?>
问题是,我无法从数据库中获取值。
在interior_testing 表中,我有type_id、name、location 和profile_pic
在interior_image_testing 表中,我有id、image_path 和type_id。
在页面上,图像未获取。
【问题讨论】:
标签: php mysqli foreach while-loop