Image Retrival

Having trouble showing many images at once

Page 1 of 1

3 Replies - 647 Views - Last Post: 04 January 2009 - 04:30 PM Rate Topic: -----

#1 genesis1989  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 16
  • Joined: 30-December 08

Image Retrival

Post icon  Posted 31 December 2008 - 12:09 AM

-- for listPhotos.php
<?php							
			$photoName = $_POST['search'];
			$host = 'localhost';
			$uName = 'praneeth';
			$passkey = '123456';
			$conn = mysql_connect($host,$uName,$passkey) or die('Cannot connect to database');
			$db = 'album';
			mysql_select_db($db) or die('cannot open database');
			
			print'<form name="Registration" method="post" action="imageDisplay.php">';
						
			$sql = "SELECT photoName FROM myPhotos";
			
			$result = mysql_query($sql) or die(mysql_error());
						
			print "<p>Select a picture:\n";
			print "<select name =\"search\">\n";
			while($row = mysql_fetch_assoc($result))
			{
				$ID = $row['photoName'];
				print "<option value=$ID>$ID</option>";
			}
				
			print"</select>\n";
			print"</p>\n";
			print'<input type="submit" name="Submit" value="Submit">';
			print"</form>";
?>



 --- for imageDisplay.php
<?php		
					
			$photoName = $_POST['search'];
			$host = 'localhost';
			$uName = 'praneeth';
			$passkey = '123456';
			$conn = mysql_connect($host,$uName,$passkey) or die('Cannot connect to database');
			$db = 'album';
			mysql_select_db($db) or die('cannot open database');
			
			$sql = "SELECT photo FROM myPhotos WHERE photoName='$photoName'";
			//$sql = 'SELECT photo FROM myPhotos';
			$result = mysql_query($sql) or die(mysql_error());
			$row = mysql_fetch_assoc($result);
			
			header("Content-type: image/jpg");
			print $row['photo'];
?>




The trouble that i am facing is... i dont know how to display all the images stored in the database at once. I can only show the images one bye one as shown above... My program lets the user select a picture from the dropdown menu then when the user clicks submit that particular picture is shown. But i dont knw how to load all the pictures kept in the database onto the browser for the user to view. I have used blog to store the pictures

Please help :(

If anyone need the whole program for them to understand please post i will send it pronto... m soo stuck :(

This post has been edited by genesis1989: 31 December 2008 - 12:11 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Image Retrival

#2 jamessy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 15-April 08

Re: Image Retrival

Posted 31 December 2008 - 03:48 AM

Hi im quite new to this but if you select all in your query it should display all the images
$sql = "SELECT * FROM myPhotos";


Was This Post Helpful? 0
  • +
  • -

#3 yoji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-January 09

Re: Image Retrival

Posted 04 January 2009 - 08:22 AM

Your on the right track.

Remove the code building the option list and change your while loop to this:

			while($row = mysql_fetch_assoc($result))
			{
				$ID = $row['photoName'];
				echo "<img src='imageDisplay.php?search=$ID' alt='$ID'/>";
			}



Change your imageDisplay.php page to use $_GETinstead of $_POST.
$photoName = $_GET['search'];




And before you make this site live, read the php manual section on security.
http://www.php.net/m...en/security.php
Was This Post Helpful? 0
  • +
  • -

#4 genesis1989  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 16
  • Joined: 30-December 08

Re: Image Retrival

Posted 04 January 2009 - 04:30 PM

Thank yogi.... I will try out ur way let u knw about it.... but rite now m heading off to uni so will get to sit down and work on this in the evening
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1