ksb24930 Posted November 12, 2006 Share Posted November 12, 2006 I have made a script to input the pictures into the database, and I can make linked files to each picture individually, but I cannot, for the life of me, figure out how to display all of the images on a page at once- not even two pictures. any thoughts? Quote Link to comment Share on other sites More sharing options...
ksb24930 Posted November 12, 2006 Author Share Posted November 12, 2006 sorry- this is the script I have been working with:$sql = "SELECT * FROM imageb";$result = mysql_query ($sql, $conn);if (mysql_num_rows ($result)>0) { $row = @mysql_fetch_array ($result); $image_type = $row["image_type"]; $image = $row["image"]; Header ("Content-type: $image_type"); print $image;}I know this script won't produce more than one image- it is the script I have been tweaking, though. Quote Link to comment Share on other sites More sharing options...
printf Posted November 12, 2006 Share Posted November 12, 2006 You need (2) scripts, (1), the script that dumps a image to the browser, and (2) the html script that creates the <img> tags that points to script (1). script (1) reads a single db row based on the id passed to it. script (2) loops all the db rows creating all the <img> tags that will be displayed on the html page -> (script 2)Sonia Quote Link to comment Share on other sites More sharing options...
ksb24930 Posted November 12, 2006 Author Share Posted November 12, 2006 excellent, thank you. Now I think I have those two scripts jumbled in my code pages, but I am unclear about how to call all the pictures- I can pass one picture id through the url, but I don't know how to display all of the images. So, what would an example of the looping script look like?thanks Quote Link to comment Share on other sites More sharing options...
AdRock Posted November 12, 2006 Share Posted November 12, 2006 You could use a while loop to loop through each of the images and display them Quote Link to comment Share on other sites More sharing options...
trq Posted November 12, 2006 Share Posted November 12, 2006 Well, the script to show the images would look very simular to the one your posted. Call it showimages.php.[code]<?php$sql = "SELECT image FROM imageb WHERE id = {$_GET['id']}";$result = mysql_query ($sql, $conn);if (mysql_num_rows ($result)>0) { $row = @mysql_fetch_array ($result); $image_type = $row["image_type"]; $image = $row["image"]; Header ("Content-type: $image_type"); print $image;}?>[/code]Now, just as an example script to loop through images 1 - 10.[code]<?php for ($i = 1; $i < 11; $i++) { echo "<img src='showimages.php?id=$i'>"; }?>[/code] Quote Link to comment Share on other sites More sharing options...
ksb24930 Posted November 12, 2006 Author Share Posted November 12, 2006 too cool, thanks all. how to I mark this post as finished? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.