samb Posted January 25, 2009 Share Posted January 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142341-help-needed/ Share on other sites More sharing options...
revraz Posted January 25, 2009 Share Posted January 25, 2009 If $_GET['name'] == 'dog' Quote Link to comment https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745854 Share on other sites More sharing options...
landavia Posted January 25, 2009 Share Posted January 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745857 Share on other sites More sharing options...
samb Posted January 25, 2009 Author Share Posted January 25, 2009 thanks for the replies but I don't really understand, I am new to php so if anyone can give more info I would appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745879 Share on other sites More sharing options...
Maq Posted January 25, 2009 Share Posted January 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745888 Share on other sites More sharing options...
samb Posted January 25, 2009 Author Share Posted January 25, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745966 Share on other sites More sharing options...
uniflare Posted January 25, 2009 Share Posted January 25, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142341-help-needed/#findComment-745993 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.