我试图从数据库中获取一些值,但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
.
在页面上,图像未被提取。