Jump to content

Recommended Posts

I need help with something I think is probably pretty simple, I have a template page which will contain a few photos  (example: cat1.jpg , cat2.jpg , cat3.jpg etc) a title (example: cats) and a short description (example: cats are also known as felines...)

 

What I want to be able to do is have links on my main page, if some clicks on the link to cats they will get the page with pics of cats, the correct title and description, if they click on dogs it will be the same template but will have dogs pictures, description etc

 

I remember seeing something a while ago that used php?name=  that seemed to work but can't find the info now.

 

Would really appreciate some help and advice.

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/142341-help-needed/
Share on other sites

W3Schools - GET  Please read through this tutorial, it will teach you the basics of the $_GET method.

 

 

that's can work but that not good

better use

 

galery.php?tag=cat

 

in script.. u just try to find cat in the description, tag or whatever you can find cat in the pic

 

What do you mean not good?  What revraz posted is the only way to GET params from the URL...

 

You should have something like this on your page:

 

if ($_GET['name'] == 'dog') {
   echo "Dog section";
}

elseif ($_GET['name'] == 'cat') {
   echo "Cat section";
}

elseif ($_GET['name'] == 'muskrat') {
   echo "Muskrat section";
}
else {
   echo "Above three sections not selected...";
}
?>




Cat Section



Dog Section



Muskrat Section





Link to comment
https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745888
Share on other sites

thanks, that is half of it, what I remember seeing ages ago was something like if you went to a url like www.yoursite.com/thispage.php?name=dog all of the images on the page would be something like dog1.jp , dog2.jpg.  if you went to www.yoursite.com/thispage.php?name=cat it was the same page except the pictures were cat1.jpg, cat.jpg instead, from what I remember this was php generated rather than having loads of pages.

 

that is what I would like to know how to do.

Link to comment
https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745966
Share on other sites

On the page you want modified:

 

Each image has to be echoed either in a loop (if ur unsure how many images will be presented) or:

 

$picnum = 0; // for the number (cat1.gif,cat2.gif)

$PIC_NAME = strip_tags($_GET['pic']); // $_GET is what is set via the URL. strip_tags makes it sort of safe. might want to use htmlentities() on it too.
echo(' <img src="$PIC_NAME$picnum.jpg" /> '); // Echo the img HTML
$picnum++; // Add 1 to the picnum (pic1.gif..pic2.gif, or it would be, pic0.gif,pic0.gif...)

 

then the next img....

$PIC_NAME = strip_tags($_GET['pic']);
echo(' <img src="$PIC_NAME$picnum.jpg" /> '); // Echo the img HTML
$picnum++; // Add 1 to the picnum (pic1.gif..pic2.gif, or it would be, pic0.gif,pic0.gif...)

 

and so on...

 

 

I hope this helps :P

Link to comment
https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745993
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.