<?php
//taskchecker.php
//Add in the database connector.
require_once ("dbconnector.php");
//Open the database.
$db = opendatabase();
//Set up the dynamic query string.
$querystr = "SELECT description FROM task WHERE thedate=➥
'" . addslashes ($_GET['thedate']) . "'";
if ($datequery = mysql_query ($querystr)){
if (mysql_num_rows ($datequery) > 0){
?>
<div style="width: 150px; background: #FFBC37; border-style: solid; ➥
border-color: #000000; border-width: 1px;">
<div style="padding: 10px;">
<?php
while ($datedata = mysql_fetch_array ($datequery)){
if (!get_magic_quotes_gpc()){
echo stripslashes ($datedata['description']);
} else {
echo $datedata['description'];
}
}
?>
</div>
</div>
<?php
}
} else {
echo mysql_error();
}
//Close the database connection.
mysql_close ($db);
?>
As you can see, you once again load in the database connector script and then call the opendatabase function. Once the database is open, it is a simple matter of creating a query that checks for any tasks that have been set up on each particular day. You then use the mysql_num_rows function to determine if a particular day has any tasks set up, and the while loop cycles through them with the mysql_fetch_array function to display all tasks. It is also important to clean up afterward. You do so by calling the mysql_close function, which will close the link to the database.
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
0 comments:
Post a Comment