I've problem in my script, the script cannot loop the data, the Results only one image
t_award
-------------------
| id | id_product |
-------------------
| 1 | 1 |
| 2 | 2 |
-------------------
t_image
------------------------------
| id | id_product | image |
------------------------------
| 1 | 1 | img1.jpg |
| 2 | 1 | img2.jpg |
| 3 | 2 | pic1.jpg |
| 4 | 2 | pic2.jpg |
------------------------------
My Query
<?php
require ("koneksi.php");
$perintah="SELECT *,
(SELECT image FROM `t_image` as tbl_t_image WHERE tbl_t_image .id_product = t_award.id_product LIMIT 1) as image_name
FROM t_award
where id='".$_GET['id']."'";
$hasil=mysql_query($perintah);
while ($data=mysql_fetch_array($hasil)) {
echo'
<div class="content-img oversize">
<img src="ipf-panel/img/images_cont_part/'.$data['image_name'].'" alt="">
</div>
';
}
?>
FYI i was delete the LIMIT 1 but error mysql_query(): Unable to save result.
Thanks for responded
mysql_*-functions. They have been completely removed in PHP 7. UsePDOorMysqliinstead. You're also wide open to SQL-injections and should use prepared statements instead of using unescaped user data directly in your query. You can use prepared statements with bothPDOandMysqli.