mysql - How to show the content of Multiple tables in SQL using PHP (Inner Join) -
given following code:
<?php include "connect.php"; $query = "select d.name,d.image,d.main_style,g.id,g.name dj d inner join genres g on g.id=d.main_style order d.name"; $exec = $mysql->query($query) or die("erreur"); $n = $exec->num_rows; if($n > 0) { echo '<!doctype html public "-//w3c//dtd html 4.01//en""http://www.w3.org/tr/html4/strict.dtd"> <html><table>'; for($i=0;$i<$n;$i++) { $row = $exec->fetch_array(); //echo '<tr><td></td><td><a href='dj.php?id=$row[id]'>$row[name]</a></td><td>$row[main_style]</td></tr>'; echo "<tr><td><img src=\"$row[d.image]\" width=\"100\" height=\"100\"/></td><td><a href='dj.php?id=$row[id]'>$row[name]</a></td><td>$row[main_style]</td></tr>"; } echo '</table></html>'; } include "disconnect.php"; ?>
as can see used inside php code $row[d.image]
display content of image
in table d , there error , how solve ? >$row[name]
, other variables working fine
the field "d.image" in mysql query doesn't transfer result, table name removed.
the respective column in result returned mysql named "image".
to solve problem, change $row[d.image]
$row[image]
you're doing other fields (id, name , main_style).
Comments
Post a Comment