Scheduling

He has: 1,380 posts

Joined: Feb 2002

hola...

I want to use PHP to create a sort of schedule on a website, and for it to auto
matically present the ones closest to the current date. All info is stored in a MySQL dB. Here's what I have so far, which I am sure isn't all correct, and I also can't figure out where to go from here. I have comments in code, so that should be self-explaining for the intent, not necessarily for the output, lol. What is not correct and what else do i need to do? Thanks

<?php
....connection stuff ...

/* Search for the components */
$query = mysql_query(\"SELECT * FROM schedule WHERE SET\"
            .\", date='
$_POST[date]'\"
            .\", location='
$_POST[location]'\"
            .\", activity='
$_POST[activity]'\"
            .\", time='
$_POST[time]'\") or die(mysql_error());

$result = mysql_fetch_array($query) or die(mysql_error());

/* Set counter */
$num = 0;

/* Order each result set into variables */
foreach(
$result) {
   
$num = $num + 1;

   
$date($num) = $result['date'];
   
$location($num) = $result['location'];
   
$activity($num) = $result['activity'];
   
$time($num) = $result['time']
}

/* Set second counter */
$num2 = 0;

/* Compare dates of result sets */
while (
$num <= $num) {
   
    /* Create array */
   
$dateARR = array();

    /* Add each date to the array */
    foreach (
$date($num)) {
       
$dateARR = .$date($num)
        };
};
/* Create the array needed */
$order = array(1, 2, 3, 4, 5, 6);

/* Sort the array */
array_multisort(
$dateARR, SORT_ASC, $order, SORT_ASC);

/* Create the variables
$date1 through $date6 and their corresponding locations, activities, and times based on the one that is closest to the current date */
?>