Laure
Laure

Reputation: 39

How do I select correctly an image out of my database?

<?php   $query="SELECT * from about";
                        $result=mysql_query($query);
                        $num=mysql_numrows($result);



                        $i=0;
                        while ($i < $num) {

                            $image=mysql_result($result,$i,"image");


                            echo "<img src='.$image.' alt=\"About\" />";

                        $i++;
                        }

        ?>

I don't get what I'm doing wrong here, can someone help me please? Thanks a lot! Cheers

Upvotes: 1

Views: 52

Answers (1)

Flask
Flask

Reputation: 4996

if(mysql_num_rows($result)) {
  while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
   echo "<img src=".$row['image']." alt=\"About\" />";
  }
}

edit: wrong string operators

Upvotes: 2

Related Questions