PDA

View Full Version : Graphic sharing



itsmsbrat2u
Feb 21st, 2012, 04:04 PM
I am trying to add a box to my site for each of my graphics so that my viewers can copy the html code for easy posting on another website

examples: ytagi, photobucket, etc

under each photo on those sites, theres a few codes that can easily be copied..

how do I add this to my site for my graphics?

stevenmw
Feb 21st, 2012, 08:23 PM
I would have the information of each image stored into a database. One specific piece of info being the files' name.

Then I would use PHP to echo out a predefined string inserting the name of the file where needed.

There are multiple ways to do this.

The simplest way I can think of is to display all content from the database on a page using a while loop.

Below is a very rough idea...(Like I said, there are multiple ways to do this. This is just one SIMPLE idea.)



$host = "localhost";
$user = "username";
$pass = "password";

$con = mysql_connect("$host",$user","$pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

$query="SELECT row FROM table";
$result=mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
echo $row["imagecode"];
echo "<br />";
echo "<a href=\"";
echo $row["imagename;
echo "\">";
echo $row["imagename"];
}
I guarantee there are so many things wrong with that code. It's just to help get my point across.

Using a while loop like that above will output all images stored in your database using the above format. Basically, each image will be displayed with a hyperlink below each one. You can of course change the hyperlink to any thing you want people to be able to copy.

Just surround database row data with the appropriate code / text.


Hope this helps you think of various ways to go about this.