0
 <?php
$query=mysql_query("SELECT model_no,images1 FROM nokia");
echo"<div>";
    while ($img = mysql_fetch_array($query))
    {
        echo $img[0];
        echo "<img src = cms/pages/images/".$img[1].">";
        }
echo"</div>";

?>

what is actually wrong in my code.. its not displaying images($img[1]) but it displays the content 'model_no' ie. $img[0]. plz any sugesstion would be greatly helpful...

6
Contributors
5
Replies
35
Views
3 Years
Discussion Span
Last Post by kgavhane12
0
<?php
$query = $mysqli->query("SELECT model_no,images1 FROM nokia");
$fetch = $query->fetch_object();
$img = $fetch->imgname;
?>
<html>
    <body>
        <img width="100%" height="100%" src="images/<?php echo $img; ?>">
    </body>
</html>
0

@sush

I can't see much wrong with your code. Have a look at the underlying html (view source) in your browser. Does the image src attribute show the value you expect it to?

//EDIT

Strike that - you've messed up the double quotes

echo "<img src = cms/pages/images/".$img[1].">";

should be

echo "<img src = 'cms/pages/images/{$img[1]}'>";

Edited by diafol

0
<?php 
$query=mysql_query("SELECT model_no,images1 FROM nokia");
  while ($img = mysql_fetch_array($query))

  @$mod_no=$img['model_no'];
  @$image=$img['images1'];
  echo $mod_no."\n";
  ?>
  <img src="cms/pages/images/<?php echo $image; ?>" width="218" height="172">
  <?php
  }

?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.