Ok, I'm still a phptard. I just started teaching myself about a week ago, and I'm running into some issues. I read through the madlib site idea on bluehat, and I'm trying to get something like that going. I finally got it so that I can connect to the db, pull info and display it. (Small step I realize)
Anyway, I'm trying to put together a site that takes a db of zip codes, cities, states and counties and puts them into some info about local jobs. Here is the code that I have so far (which is not much):
So like I said, I have a begining idea of how to get the info. My biggest question at this point is how do I go about dynamically generating these pages? Coding them by hand like that isn't realistic for a huge database. I just don't really know where to start looking to have those pages generated. How do I automate the creation of the different pages? A bonus would be to have the pages named {specific job}-in-{city}-{state}-{zip}.php
If someone could point me in the right direction I'd appreciate it!
Anyway, I'm trying to put together a site that takes a db of zip codes, cities, states and counties and puts them into some info about local jobs. Here is the code that I have so far (which is not much):
PHP:
<?php
function &connectToDb($host, $dbUser, $dbPass, $dbName)
{
// Make connection to MySQL server
if (!$dbConn = @mysql_connect($host, $dbUser, $dbPass)) {
return false;
}
// Select the database
if (!@mysql_select_db($dbName)) {
return false;
}
return $dbConn;
}
$host = 'localhost'; // Hostname of MySQL server
$dbUser = 'root'; // Username for MySQL
$dbPass = ''; // Password for user
$dbName = 'zips'; // Database name
$dbConn = &connectToDb($host, $dbUser, $dbPass, $dbName);
$sql = "SELECT * FROM zips WHERE ID=1"; //only selects the one set of city data
$results = mysql_query($sql);
while ($row = mysql_fetch_array($results)) {
$city = $row['city'];
$state = $row['state'];
$zip = $row['ZIP'];
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jobs in <?php echo "$city, $state, $zip"; ?></title>
</head>
<body>
Hello, it looks like you are looking for a job in <?php echo "$city, $state, $zip"; ?>. I know how frustrating it can be to find a job in <?php echo $city ?> because I used to live there. Here are some suggestions for employment in <?php echo "$city, $state"; ?> and the surrounding area.
</body>
</html>
If someone could point me in the right direction I'd appreciate it!