5 Replies - 7667 Views - Last Post: 19 January 2011 - 09:17 AM Rate Topic: -----

#1 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Simple picture upload script

Posted 19 January 2011 - 03:41 AM

Hi,

long time no see!

I need a simple code to upload an image to a page on a website, and then have a commenting system below the image.

I have PHP code to upload an image to an image folder but not sure how I go about uploading and displaying the image on the page.

this IS NOT homework, this is just a little project that I'm working on purely for my own entertainment purposes, any help would be greatly appreciated, any links etc.

Thanks for your time.

Is This A Good Question/Topic? 0
  • +

Replies To: Simple picture upload script

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: Simple picture upload script

Posted 19 January 2011 - 03:54 AM

The new search bar is very handy. How about this:
http://www.dreaminco...mages-with-php/
Was This Post Helpful? 0
  • +
  • -

#3 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Simple picture upload script

Posted 19 January 2011 - 04:30 AM

View PostDogstopper, on 19 January 2011 - 03:54 AM, said:

The new search bar is very handy. How about this:
http://www.dreaminco...mages-with-php/


thank you very much, I did search but I wasn't sure what I found was any use to me (if that makes sense) this tutorial is very helpful indeed!

cheers
Was This Post Helpful? 0
  • +
  • -

#4 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: Simple picture upload script

Posted 19 January 2011 - 05:58 AM

Hi,

If you are already uploading the image to your web server all you need to do is make an entry into a table of your database that corresponds with the image name. Then use that information as the src attribute of your <img> tag.
Was This Post Helpful? 0
  • +
  • -

#5 Addio569  Icon User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 316
  • Joined: 26-November 08

Re: Simple picture upload script

Posted 19 January 2011 - 06:26 AM

i'm using this part of the script to display the images..

<?php 
// Get our database connector
require("includes/conn.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Dream in code tutorial - List of Images</title>
	</head>

	<body>
	
		<div>

			<?php	
				// Grab the data from our people table
				$sql = "select * from people";
				$result = mysql_query($sql) or die ("Could not access DB: " . mysql_error());

				while ($row = mysql_fetch_assoc($result))
				{
					echo "<div class=\"picture\">";
					echo "<p>";

					// Note that we are building our src string using the filename from the database
					echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br />";
					echo $row['fname'] . " " . $row['lname'] . "<br />";
					echo "</p>";
					echo "</div>";
				}

			?>
		
		</div>
	</body>
</html>



how would I organise this, at present the images are just displayed under each other, I would like them in rows, say 2 across, how do I acheive this?? css divs??

cheers
Was This Post Helpful? 0
  • +
  • -

#6 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: Simple picture upload script

Posted 19 January 2011 - 09:17 AM

Yes, the layout of the images would be a CSS issue. You could use divs sure.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1