Jump to content

Creating template pages but all have different content?


mcc_22ri

Recommended Posts

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!

Link to comment
Share on other sites

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>";
  }

?>

Link to comment
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.