I am writing an events program to help my dad manage his speaking schdule. The database setup is in the attached image.
I need to say something like this: take begin_date and end_date, if begin_date == end_date, echo $begin_date
else if begin_date(month) is not equal to end_date month, echo begin_date_month-begin_date_day - end_date_month-end_date_day, end_date_year (like this January 28-February 3, 2006)
else if begin_date_month is equal to end_date month, echo begin_date_month-begin_date_day - end_date_day, end_date_year (like this January 28-30, 2006)
Here's the code I currently use to get the events from the database.
$connection = @mysql_connect("localhost",$user,$password) or die("Could not connect to database...");
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM events WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)
$result = @mysql_query($query,$connection)or die("failed on query: ". mysql_error());
while($row = mysql_fetch_array($result))
{
$venue = $row["venue"];
$event_name = $row["event_name"];
$begin_date = $row["begin_date"];
$end_date = $row["end_date"];
$location = $row["location"];
$commissioning = $row["commissioning"];
$contact_name = $row["contact_name"];
$contact_email = $row["contact_email"];
?>
<tr>
<td class="box"><hr><strong><? echo $begin_date ; ?></strong><br><br><? echo $venue; ?><br><? echo $location; ?><br><? echo $contact_name; ?><br><a href="mailto:<? echo $contact_email; ?>"><? echo $contact_email; ?></a><br><? if ($commissioning == 'yes')
{
echo '<img src="images/commissioning.gif">';
}
else if ($commissioning == 'no')
{
echo '';
} ?>
</tr>
<?
//end while
}
?>
Any help at all would be greatly apprecited. I've only been programming with php/mysql for about a month, so I'm still a n00b.