php - Error with image display -
please check below code , me out if going wrong in image display code
untitled document
<body> <p>how display image</p> <p>image not seeingd</p> <?php $con= mysql_connect("localhost","root",""); $d= mysql_select_db("matrimonial",$con); $id=$_request['id']; $sql = "select * advertiesment s_no ='1'" or die(mysql_error()); $result = mysql_query($sql,$con); if($rows=mysql_fetch_assoc($result)) { $image = $rows['filepath']; echo "<img style='width:150px;height:150px' src='$image'>"; echo "<br>"; } ?><p>how display image</p> </body> </html>
if($rows=mysql_fetch_assoc($result))
the condition bad. if have more results sql query,you need use while
.
while ($rows = mysql_fetch_assoc($result)) {...
if have one, remove if
:
$rows = mysql_fetch_assoc($result); echo ...
edit:
$image = $rows['filepath'] . '/' . $rows['filename'];
Comments
Post a Comment