mysql - display image using php from phpmyadmin for product items not working -


i putting links book items in mysql phpmyadmin. images stored in img folder in htdocs. cannot seem display images.

/i read book infor first database

<?php  include ("db_con.php");   //read books $book_query= "select * book";  $run_query=mysqli_query($dbcon, $book_query);  $isbn=array(); $author=array(); $book=array(); $page=array(); $weight=array(); $publisher=array(); $edition=array(); $language=array(); $img=array();    if(mysqli_num_rows($run_query)>0)   {       while( $row = mysqli_fetch_assoc( $run_query)){          array_push($isbn,$row['isbn']);         array_push($author,$row['author']);         array_push($book,$row['book']);         array_push($page,$row['page']);         array_push($weight,$row['weight']);         array_push($publisher,$row['publisher']);         array_push($edition,$row['edition']);         array_push($language,$row['language']);         array_push($img,$row['img']);       }     //echo "$img[0]";     //print_r($img);  }   mysqli_close($dbcon);   ?> 

then try display it

<?php include ("local_book_db.php"); ?> <section id="recommended">         <p id="typenew">recommended</p>          <a href=""><img src="$img[0]" alt="aaa">a book</a>        </section> 

it displays alt string not image how can display image?

thanks

you need 'echo' image url, i'm assuming in $img array.

the correct code :

 <a href=""><img src="<?php echo $img[0]; ?>" alt="aaa">a book</a> 

hope helps! code work if $img array , $img[0] holds image url.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -