mcc_22ri Posted May 18, 2012 Share Posted May 18, 2012 Hi Everyone, Please excuse my lack of tech. terminology. I'm in the learning stages of php/myslq Do you know how both the below pages are very similiar. The only thing that's different is the actual location(s). My question is, is the same code being used for all of these template pages? If so, how does the code know differentiate between different states/cities/? Does each state or even city have a different template? <<--- Thinking out loud here, I don't believe so because that would defeat the purpose of php/mysql. What do you think? http://cars.oodle.com/regions/illinois/ http://cars.oodle.com/regions/indiana/ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> http://cars.oodle.com/regions/illinois/ <<--- Assuming this code is being used on the "state template" how does the php/mysql code on this page know how to show data from the Bloomington area of Illinois? (assuming it's not custom code for the above page) http://cars.oodle.com/used-cars/bloomington-il-area/ <<--- Assuming this code is being used on the "cars template" how does the php/mysql code on this page know how to show data from the Bloomington area of Illinois? (assuming it's not custom code for the above page) Thanks everyone! Quote Link to comment https://forums.phpfreaks.com/topic/262738-creating-template-pages-but-all-have-different-content/ Share on other sites More sharing options...
downah Posted May 18, 2012 Share Posted May 18, 2012 you create a loop where you pull out the data from your database <?php //get the state from the url $state = mysql_real_escape_string($_GET['state']); //take data from database where the state is the state from the url $result = mysql_query("SELECT * FROM TABLE WHERE state = '$state'"); //loop so all data is shown while($row = mysql_fetch_array($result)) { //show statename echo $row['statename']; echo "<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/262738-creating-template-pages-but-all-have-different-content/#findComment-1346623 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.