how to load images from the database when i click the selection on the list box and it will be displayed on a particular frame. im using xhtml page, php and mysql.
thanks in advance..[/quote]
how to load images from database?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
If you're storing the raw binary image data in the database you'll have to create a script that retrieves a single image at a time sending the proper headers and things so a browser can properly display the images. Each time you want to reference one of these images it'll have to point to this script. Storing images in a database requires twice (at minimum) the RAM needed to hold the binary and will slow page response speeds among other things.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
This might help
Dear lanny,
This http://www.devarticles.com/c/a/MySQL/Bl ... and-MySQL/link might help you.
I have taken the reference from this url earlier.
Cheers,
Dibyendra
This http://www.devarticles.com/c/a/MySQL/Bl ... and-MySQL/link might help you.
I have taken the reference from this url earlier.
Cheers,
Dibyendra
-
The-Master
- Forum Commoner
- Posts: 45
- Joined: Sun Aug 07, 2005 9:51 am
- Location: Israel
you can store the files' name like "smile.jpg"
in a DB named "image_db" for example...
that is built like this:
id, image_name, image_format
and when you pull data you can display it like this:
test it and tell me if this what you wanted...
in a DB named "image_db" for example...
that is built like this:
id, image_name, image_format
and when you pull data you can display it like this:
Code: Select all
<html>
<head>
<title>something</title>
</head>
<frameset rows="48,*" frameborder=0 border=1>
<frame src="the_frame_with_the_list_box.htm" scrolling=no name="topframe">
<frame src="the_frame_that_shows_the_images.htm" name="bottomframe">
</frameset>
<body>
<form name="framecombo">
<select name="framecombo2" size=1>
<?php
$query = "SELECT * FROM image_db";
$result = mysql_query($query);
while($r=mysql_fetch_array($result)) { // this will display all the images in the db in a list
$img=$r["image_name"];
$img_f=$r["image_format"];
echo "<option value='images/$img.$img_f'>$img</option>";
}
?>
</select> <input type="button" value="Go!" onClick="jumpbox()"></p>
</form>
// the JScript...
<script language="javascript">
<!--
var openmode=1
var targetframe="particular_frame" // change this to the name of the particular frame you want
function jumpbox(){
var destination=eval("window.parent."+targetframe)
var thebox=document.framecombo
if (openmode==2)
destination=window.parent
destination.location=
thebox.framecombo2.options[thebox.framecombo2.selectedIndex].value
}
//-->
</script>
// the JScript end...
</body>
</html>