About the JobBoard
next->


9/13/00 - Like the rest of the InterNetWorkers' site, the JobBoard makes use of use of , albeit more specialized. PHP is a server-side, cross-platform, HTML embedded scripting language similar to or , except that it's . The JobBoard also uses for its database. MySQL is a relational database management system. See for more specifics.

The entire JobBoard consists of three pages, and a table in the db. This is what the table looks like.
+--------------------+-------------+-----+--------+
| Field              | Type        | Null| Default| 
+--------------------+-------------+-----+--------+
| company_name       | varchar(150)| YES | NULL   |
| company_location   | varchar(250)| YES | NULL   |
| company_contact    | varchar(250)| YES | NULL   |
| company_email      | varchar(250)| YES | NULL   |
| company_website    | varchar(250)| YES | NULL   |
| company_description| text        | YES | NULL   |
| job_title          | varchar(150)| YES | NULL   |
| job_ref_code       | varchar(150)| YES | NULL   |
| job_description    | text        | YES | NULL   |
| job_requirements   | text        | YES | NULL   |
+--------------------+-------------+-----+--------+
You can see that each row in the table will have a field name (describing its content), a field type, an indicator of null state (that is, can the field be empty, or NULL), and the default value. Please note that I'm not a db expert by any stretch of the imagination, so my descriptions are likely to be slightly imprecise. Also, I've removed some of the more sensitive information, for security reasons.

To continue, we have a table in MySQL; what good is it? Well, if there is a set of information in that table, we can call it on the page /jobboard/index.php3.
<?       

$date = date("z");  //get the date
$checkdate = (date("z") - 30); // get the date (-30 days)

	// Connect to the Database
$link = mysql_connect("path.to.the.db", "username", "password");
	
	// list the tables in the db
$result = mysql_list_tables ("InterNetWorkers");

	// create an array that contains the table names above
$tb_names[$i] = mysql_tablename ($result, "0");

	// Queries don't care for \ characters, and php doesn't  
	// like quotes- this takes care of those issues. 
$query_string = " != \"\" "; 

	// the actual db query
$Find_jobs = mysql_query ("SELECT * FROM jobboard 
             WHERE company_name $query_string AND 
             MOD(timeStamp, 365) >= $checkdate 
             ORDER BY posted_on DESC");
	
The heart of this is the mysql_query. In plain English, it sez, "Select everything from the jobboard when the field 'company_name' isn't empty, and the date of the record isn't more than 30 days old and then sort them based on the date they were posted in descending order."

So far, so good. But this query doesn't do anything yet. So we use the while loop below to build an array based on the $mysql_query above, cycle through the information the database contains, and output the info to the page (using the print command).

while($row = mysql_fetch_array($Find_jobs)) {
	print "Company Name: $row[1]";
	print "Company Location: $row[2]";
	print "Company Contact: $row[3]";
	};
 
This is a really simplified version of what's happening on the actual InterNetWorkers page - you can obviously put lots of html and formatting info inside the print ""; statement. What's not so obvious is that you can evaluate the contents of the array, and add an if function to decide how and whether to display the information.
while($row = mysql_fetch_array($Find_jobs)) {

		// if row2 is not empty, display it.
	if ($row[2] != "") { 
		$row[2] = "Company Location: $row[2]";
		}

	print "Company Name: $row[1]";
	print "$row[2]";
	print "Company Contact: $row[3]";
	};

mysql_close ($link); //close the connection to the db
?>
Getting the information into the database is somewhat more convoluted - see JobBoard Pt. II.

~Joe K



next->
Questions? Comments? Send them to Joe K