Rewriting URLS using MySql Database as Variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mcc_shane
Forum Newbie
Posts: 22
Joined: Sat May 12, 2012 1:47 pm

Rewriting URLS using MySql Database as Variables

Post by mcc_shane »

Hi,

I'm trying to use certain keywords/phrases from my mysql database and taking that information and using it in my urls/meta tags.

These are the steps I've already done.

1. I've connected to my database
2. I've declared the variables
3. I tested the variables in a sentece to see if they were working. It seems they are. See links below.

http://whatsmyowncarworth.com/auto/table.php (this is my data that I'm playing with)
http://whatsmyowncarworth.com/auto/urls.php (this is variables that are working. I create a $city and $state variable)

For me this is where the confusion starts to come into play ....

Here's my question. What do I need to do next? Do I need to write a script or something along those links to create my URLS? what would that script look like? Does it have to be a different page?

Thanks for everyones help!

Below is the code for my website so far.

http://whatsmyowncarworth.com/auto/urls.php

Code: Select all

<?php 
include('init.php');

$sql = "SELECT State, City FROM cars";

$result = mysql_query($sql);
$row = mysql_fetch_array($result);

$state = $row['State'];
$city = $row['City'];

echo 'Hi, I\'m from '. $state . '. I live in the city of '. $city;


?>
Post Reply