you are making a calendar right?

so if you make a row per month and a table for every year, and make the HTML table just wide enough to get seven days, all you need to do is make the table so that you have ID in one col year in another, month in another, date in a fourth and events in the last.

Then the php script should be simple enough - so long as you define width before looping, you should be fine.
If you have the variables stored in the URL as GET strings, you can have different years, months and days.

CODE

<?php
//script for one month extraction
// Connect to MySQL

$table = $_GET['year'];
$month = $_GET['month'];

echo '<p align="center"> \n '.ucfirst($month).'$nbsp'.$table.'</p> \n \n';
echo '<table width="whateverwidthyouneed" border="1"> \n ';
echo '<tr> \n ';

$result = mysql_query("SELECT * FROM $table WHERE month = $month") or die(mysql_error());

while($row = mysql_fetch_array( $result )) {
        echo '<td> \n';
        echo '<table> \n ';
        echo '<tr> \n ';
        echo '</td> \n ';
        echo $row['date'].' \n ';
        echo '</td> \n ';
        echo '</tr> \n ';
        echo '<tr> \n ';
        echo '<td> \n ';
        echo $row['event'].' \n ';
        echo '</td> \n';
        echo '</tr> \n ';
        echo '</table> \n ';
        echo '</td> \n';
}

?>


That should do it for the 'month' part....
The only thing is that the page has to be wide enough so that even in 800*600 screen resolution, people can have seven boxes in a row.

Hope that helped tongue.gif
Good luck!

 

 

 


Reply