Whether it is the website design or the Office system, the shopping mall, all need to display the picture on the webpage, the picture is extracts from the database, next we take a look through the picture path saves and displays the picture the way:
First, to save the path to the picture in the table, Note: The path is from the WWW directory instead of from the root of the disk,/on behalf of the WWW directory:
The table img is the stored picture path, that is, the path under the WWW directory, since the table is stored in the path, then we can use the PHP link database to obtain:
<?PHPrequire"DBDA.class.php";//calling the encapsulation class $db=NewDbda (); $sql= "SELECT * FROM book"; $arr=$db->query ($sql); foreach($arr as $v)//iterate through the contents of each column { //The image gets the path with an IMG tag, because the traversal of the IMG is $v[5], so the path is $v[5] Echo"<div id= ' Hang ' ><a href= ' gouwu.php?bkid={$v[0]} ' >$v[5]} ' ></a> <div class= ' JG ' ><a href= ' gouwu.php?bkid={$v[0]} ' >{$v[1]}</a></div> <div class= ' JG ' style= ' color:red ' >{$v[3]} meta </div> </div>"; }?>
This way you can get the picture through the path, which is very convenient and efficient:
Save pictures and display pictures in PHP database