Jump to content

pages.php?id=$var


Recommended Posts

i am attempting to create a website that will display all of my graphic work. i just recently finished creating code to easily a new graphic to the list. it uploads the name, notes, and image to the mysql database, as well as create a thumbnail and saves it as a different jpeg as well. the thumbnail will be shown on the frontpage, and the when you click on it, it will go to the actual page, including a bigger image, as well as the title, author notes, and spaces for comments.

now that i'v explained that, here is my question:
as i explained, i want there to be a different page for each individual graphic. so would the easiest way to be to do it something like:
[b][color=red]pages.php?id=$graphicID[/color][/b]
and then depending on the number at the end, it will display different graphics. or is their an easier way?
if that is a good way to do it, will someone please point me to a tutorial that explains more about how to set something like that up?
Link to comment
Share on other sites

it's  fairly simple really, you've already done the hard parts

if you have the entries in a database you would do a SELECT statement with
an asterisk (*) for an identifier. Here is a great tutorial to get things from your database.
http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php

Other than that, you were on the right track. Loop over the array and print your links into
the thumbnails or list or whatever. For the html you can do like you suggested, for the source
of the href tag, use:

<?
echo "<a href=\"page.php?image=".$array[$n]."\">Link to $array[$n]</a>\n";
?>

Then on the page you link to place at the beginning something like:

<?
if (isset($_GET['image'])) {
  $image = $_GET['image'];
}
?>

and then later on down the page where you want the image to be displayed, just use:

<img src="<? echo $image; ?>" />

I've done something just like this on my personal page www.scottwillmanvfx.com you can check out my urls
Link to comment
Share on other sites

sorry for the delay... the value of $_GET['image'] is whatever follows the = in the url. (page.php?image=1234.jpg) You can define how you want it to relay the message any way you wish, but if page.php?image=1234.jpg is the url, then $_GET['image'] equals 1234.jpg. Saying $image=$_GET['image']; makes $image equal to 1234.jpg as well. Then you can just pop a directory path on the front of $image and put it in an html image tag. you don't have to use $image, you could just use the GET statement, but I think it looks better the other way.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.