PHP code using the $_GET function (need help!)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
instantdeath
Forum Newbie
Posts: 1
Joined: Sat Jul 25, 2009 12:53 am

PHP code using the $_GET function (need help!)

Post by instantdeath »

So I'm creating a photography portfolio for my website, and I'm using PHP to have a more dynamic portfolio.

What I'm wanting is to be able to have a certain number of images, let's say 3, when users click portfolio, which for example, let's say goes to:

http://iaminstantdeath.com/test/index.php

When you get there, it currently only shows the links to page1 and page2. I want 3 images to be at the top, and then change when you click page1 and page2.

If you click page1 and page2 right now, it will do as I want it to, and the url will become:
http://iaminstantdeath.com/test/index.php?page=1

If you can help me get what I want, please help me out!

Here's the code I'm using:

Code: Select all

<?php
 
$tmp = $_GET['page'];
if($tmp == "1"){
echo "<a href=\"http://iaminstantdeath.webs.com/portfolio/4.jpg\" rel=\"lightbox\" title=\"<br>© instant death photography\"><img src=\"http://iaminstantdeath.webs.com/portfolio/4.jpg\" height=\"150\" width=\"100\" border=\"0\" /></a>&nbsp;";
echo "<a href=\"http://iaminstantdeath.webs.com/portfolio/5.jpg\" rel=\"lightbox\" title=\"<br>© instant death photography\"><img src=\"http://iaminstantdeath.webs.com/portfolio/5.jpg\" height=\"150\" width=\"100\" border=\"0\" /></a>&nbsp;";
echo "<a href=\"http://iaminstantdeath.webs.com/portfolio/6.jpg\" rel=\"lightbox\" title=\"<br>© instant death photography\"><img src=\"http://iaminstantdeath.webs.com/portfolio/6.jpg\" height=\"150\" width=\"100\" border=\"0\" /></a>&nbsp;";
}
 
$tmp = $_GET['page'];
if($tmp == "2"){
echo "<a href=\"http://iaminstantdeath.webs.com/portfolio/7.jpg\" rel=\"lightbox\" title=\"<br>© instant death photography\"><img src=\"http://iaminstantdeath.webs.com/portfolio/7.jpg\" height=\"150\" width=\"100\" border=\"0\" /></a>&nbsp;";
echo "<a href=\"http://iaminstantdeath.webs.com/portfolio/8.jpg\" rel=\"lightbox\" title=\"<br>© instant death photography\"><img src=\"http://iaminstantdeath.webs.com/portfolio/8.jpg\" height=\"150\" width=\"100\" border=\"0\" /></a>&nbsp;";
echo "<a href=\"http://iaminstantdeath.webs.com/portfolio/9.jpg\" rel=\"lightbox\" title=\"<br>© instant death photography\"><img src=\"http://iaminstantdeath.webs.com/portfolio/9.jpg\" height=\"150\" width=\"100\" border=\"0\" /></a>&nbsp;";
}
 
?>
 
<head>
 
<script type="text/javascript" src="../prototype.js"></script>
<script type="text/javascript" src="../scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="../lightbox.js"></script>
<link rel="stylesheet" href="../lightbox.css" type="text/css" media="screen" />
 
<body>
 
<?php echo "<br><table align=\"right\"><a href=\"index.php?page=1\">page1</a></table>";?>
<?php echo "<br><table align=\"right\"><a href=\"index.php?page=2\">page2</a></table>";?>
 
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: PHP code using the $_GET function (need help!)

Post by cpetercarter »

Perhaps you need something like this :

Code: Select all

if (!isset($_GET['page']}  {
//code to put the images you want on the page
}
Please remember to close the <head> and <body> sections with </head> and </body>, and move the head section so that it is at the top of your script.
Post Reply