MySQL Forums
Forum List  »  MySQL Administrator

Re: Get image source from mysql database
Posted by: Barry Galbraith
Date: September 19, 2009 07:47PM

The answer depends on your client you are using to access the database.

If you are using php to build a web page, then could use something like this.

==== untested code ====
<?xml version="1.0" encoding="UTF-8"?>
<gallery>
<album title="Nature" description="Images of trees, lakes and flowers" lgPath="slideshow/baChurch/album1/large/">
<img src="baChurch_01.jpg" />
<img src="baChurch_02.jpg" />

<?php
// connect to the database

$mysqli = mysqli_connect('localhost','user','password', 'database');
$result = mysqli_query($mysqli, "SELECT url FROM url_table");
While ($row = mysqli_fetch_array($result)){
?>
<img src= "<?php echo $row['url']; ?>" />
<?php
}
// free the result when you are finished with it
mysqli_free_result($result);
// close the database connection
mysqli_close($mysqli);

?>
</album>
</gallery>

Good luck,
Barry



Edited 4 time(s). Last edit at 09/20/2009 03:40PM by Barry Galbraith.

Options: ReplyQuote


Subject
Written By
Posted
Re: Get image source from mysql database
September 19, 2009 07:47PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.