kabs Posted October 30, 2007 Share Posted October 30, 2007 I have a php website. There is a dynamic page that works like this: www.mywebsite/carpage.php?car_id=1 www.mywebsite/carpage.php?car_id=2 www.mywebsite/carpage.php?car_id=3 ....etc. to car_id=500 The variable (car_id=1, 2, 3, ...500) is passed from the url to the sql query in the page code. Let's say 1= Ford Pickup, 2=Ford Focus, 3=Dodge Durango. What I want to do is create a bunch of pages like this: www.mywebsite/ford_pickup.php www.mywebsite/ford_focus.php www.mywebsite/dodge_durango.php In these pages, I'd like the variable to be hard-coded into the sql query ideally. if I still have to have the vairable in the url, that would be the end of the world, but ideally I can remove all the variable strings from the url. How I can do this now: Open a page in Dreamweaver, edit the code to hard-code the correct car_id in the sql query. Save AS the file as ford_pickup.php. Repeat 500 times. I figure there is something out there to help me with this, but all searches for Auto Generate Webpages and similiar are yielding no-so-good results. Any thoughts on how to get on the right track here much appreciated!! Quote Link to comment https://forums.phpfreaks.com/topic/75302-auto-generate-hundreds-of-pages/ Share on other sites More sharing options...
sKunKbad Posted October 30, 2007 Share Posted October 30, 2007 kabs, don't do that. Look for some tutorials on Mod Rewrite. Quote Link to comment https://forums.phpfreaks.com/topic/75302-auto-generate-hundreds-of-pages/#findComment-380854 Share on other sites More sharing options...
teng84 Posted October 30, 2007 Share Posted October 30, 2007 better to use dynamic pages! that is why we have PHP having a hundreds of pages is very hard to maintain and time consuming Quote Link to comment https://forums.phpfreaks.com/topic/75302-auto-generate-hundreds-of-pages/#findComment-380857 Share on other sites More sharing options...
bwochinski Posted October 30, 2007 Share Posted October 30, 2007 As has been said, you really don't want to generate hundreds of pages. The ideal solution for this situation is to use ModRewrite. I'd recommend adding another directory to your pathname, to keep the .htaccess simple. Something along the lines of: http://www.carwebsite.com/model/ford focus Then in the /model/ folder put an .htaccess file with something like this... Options -Indexes RewriteEngine on RewriteRule ^(.*)$ /model/$1/ [R,NC] RewriteRule ^(.*)/$ /model/carpage.php?model=$1 [NC] You would still do your processing in /model/carpage.php, pulling records by model. Be sure to do plenty of data checking. Quote Link to comment https://forums.phpfreaks.com/topic/75302-auto-generate-hundreds-of-pages/#findComment-380862 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.