JamieR
10-08-2004, 12:37 PM
right.......prob is below
|
||||
php scriptJamieR 10-08-2004, 12:37 PM right.......prob is below JamieR 10-08-2004, 12:37 PM i'm trying to set up a archive page for my site. i have loads of plain html pages i.e. 12august04.html but i want to create a system using php where i can use this instead to call the script - archive.php?id=6 instead of having loads of php pages. The only thing is i dont want to use MySQL to call this - i just want to link loads of XHTML transitional web pages with a .php extension together by using the archive.php?id=6 call method to show each page as the id number changes. How do I do this, and can someone give me a PHP script to do this without usng MySQL? Regards -weazel Hawkmoon 10-08-2004, 05:51 PM A quick and easy solution: <? if($_REQUEST["id"]!="") { $page = "pageName{$id}.html"; include($page); } ?> JamieR 10-08-2004, 10:50 PM ok thanks but where "pageName{$id}.html" is, do I create put in "12August{$1}.html t show the id value? Hawkmoon 10-08-2004, 11:02 PM Not sure what you are trying to say. My guess is you wanna know how to access the filename. Personally I would do it this way: yyyymmdd.html so page id "20041008" would bring up 20041008.html which would be the file representing October 8th 2004. Kurashu 10-08-2004, 11:02 PM It'd be better to make it: $id = ($_REQUEST["id"] != "") ? (1) : ($_REQUEST["id"]; $page = "pagename_" . $id . ".php"; include ($page); That'll check to see if $_REQUEST["id"] is set to "", and if it is it'll make it one, if not it retains the value. Then for the page names, it should be pagename_1.php (or whatever number it is). JamieR 10-08-2004, 11:12 PM thanks but all i get is two of my web pages which I have called in the script being displayed on the page. What i want is : /archive.php?id=1 to show /20040901.php /archive.php?id=2 to show /20040902.php -weazel Hawkmoon 10-08-2004, 11:25 PM Since you don't want to use MySQL you can create an array with the various filenames. <? $id = $_REQUEST["id"]; $arrFile[1] = "20040901.php"; $arrFile[2] = "20040902.php"; $arrFile[3] = "20040903.php"; //etc... if($id!="") { $page = $arrFile[$id] } else { $page = $arrFile[1]; } include($page); ?> JamieR 10-08-2004, 11:32 PM okay thanks for the help. JamieR 10-09-2004, 10:08 AM it works but I have 2 pages one after each other, but the /archive.php?id=1 bit does work any ideas? Hawkmoon 10-09-2004, 03:38 PM So you have 2 pages that you want to include on the same page? ie you want to include 20040902.html AND 20040903.html on the same page? if so...just alter the code this way: <? $id = $_REQUEST["id"]; $arrFile[1] = "20040901.php"; $arrFile[2] = "20040902.php"; $arrFile[3] = "20040903.php"; //etc... if($id!="") { $page = $arrFile[$id] } else { $page = $arrFile[1]; } include($page); //If you include 20040902.php ALSO include 20040903.php if($id=="2") { include({$arrFile[($id+1)]}); } ?> JamieR 10-09-2004, 05:11 PM no what i want is 20040909.html one one page as /archive.php?id=1 and 20040910.html as /archive.php?id=2. what i have at the moment is 20040909.html AND 20040910.html underneath the 20040909.html page which is being represented as /archive.php?id=1. I only want 20040909.html to be displayed as /archive.php?id=1 and 20040910.html to be displayed as /archive.php?id=2. Hawkmoon 10-09-2004, 05:17 PM Dude, then look at the original code I gave you. Code for archive.php: <? $id = $_REQUEST["id"]; //$id will equal whatever you pass from the Query String $arrFile[1] = "20040909.php"; $arrFile[2] = "20040910.php"; $arrFile[3] = "20040911.php"; //etc... if($id!="") { $page = $arrFile[$id] } else { $page = $arrFile[1]; } include($page); ?> This will do EXACTLY what you just said you wanted. If you want to access 20040910.html then visit: archive.php?id=2 JamieR 10-09-2004, 05:31 PM thanks man but i've got a parse error on the code that you gave me: I have uploaded the array code you gave me to my web server: http://www.jamierees.co.uk/phparchive.php?id=3 Please take a look and tell me what you think Hawkmoon 10-09-2004, 05:39 PM It's missing a semi-colon. I fixed it in the code below <? $id = $_REQUEST["id"]; //$id will equal whatever you pass from the Query String $arrFile[1] = "20040909.php"; $arrFile[2] = "20040910.php"; $arrFile[3] = "20040911.php"; //etc... if($id!="") { $page = $arrFile[$id]; //<--this was the line missing the semi-colon } else { $page = $arrFile[1]; } include($page); ?> cyphix 10-09-2004, 05:41 PM <? $id = $_REQUEST["id"]; //$id will equal whatever you pass from the Query String $arrFile[1] = "20040909.php"; $arrFile[2] = "20040910.php"; $arrFile[3] = "20040911.php"; //etc... if($id!="") { $page = $arrFile[$id]; } else { $page = $arrFile[1]; } include($page); ?> Try that code... was missing the closing ";" on one of the lines. ;) JamieR 10-09-2004, 05:44 PM okay thanks but i now have the same page displayed twice (one underneath the other) I also have a "Warning: main(): stream does not support seeking in /home/www/jamieree/work.php on line 13" error on the page. http://www.jamierees.co.uk/work.php?id=3 any ideas? -Jamie JamieR 10-09-2004, 05:47 PM dam sorry its working now guys, cheers for the help - i was looking at the wrong page with the wrong script |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum