I am working on an Events Site in which we list minimal details on multiple events and when you click on one event it selects it from the Database and displays all the information.
Basically I can't figure out how to query a single event from the list of events. Or how the script would work if you typed in the url (exp: eventsite.com/events.php?url=2009-01-01-Event-Name/)
Here's my Event.php script:
<?php
function setinclude(){
$levels = substr_count($_SERVER['PHP_SELF'],'/');
$root = '';
for($i = 1; $i < $levels; $i++){$root .= '../';}
set_include_path($root);
}
setinclude();
// Make a MySQL Connection
db.php';
if(isset($_GET['url']))
{
$get_event = $_GET['url'];
}
//MySQL Query
$query = "SELECT title, DATE_FORMAT(start_date, '%M %d'), DATE_FORMAT(end_date, '%M %d %Y'), city, state, description, site, email, contact, phone1, phone2, phone3, fax, vendor
FROM motorcycleevents
WHERE url='$get_event'";
$result = mysql_query($query) or die('Error, The Event You are looking for is not here.');
//print the event information
while(list(
$title, $start_date, $end_date, $city, $state, $description, $site, $email, $contact, $phone1, $phone2, $phone3, $fax, $vendor
) = mysql_fetch_array($result))
{
echo "<center><p class=\"HLarge\">";
echo "$title";
echo "</p></center>";
echo "<p class=\"CEvent\">";
echo "<table class=\"event\" cellspacing=\"10\" cellpadding=\"10\">";
//Event Date
echo "<tr>";
echo "<td>";
echo "<b>DATE</b>";
echo "</td>";
echo "<td>";
echo "$start_date";
echo " - ";
echo "$end_date";
echo "</td>";
echo "</tr>";
//City/State
echo "<tr>";
echo "<td>";
echo "<b>CITY / STATE</b>";
echo "</td>";
echo "<td>";
echo "$city";
echo ", ";
echo "$state";
echo "</td>";
echo "</tr>";
//Description
echo "<tr>";
echo "<td><b>DESCRIPTION</b></td>";
echo "<td>";
echo "$description";
echo "</td>";
echo "</tr>";
//Website
if ( $site == "--" ) {
echo "";
} else {
echo "<tr>";
echo "<td><b>WEBSITE</b></td>";
echo "<td>";
echo "$site";
echo "</td>";
echo "</tr>";
}
//E-Mail
if ( $email == "--" ) {
echo "";
} else {
echo "<tr>";
echo "<td><b>EMAIL</b></td>";
echo "<td>";
echo "$email";
echo "</td>";
echo "</tr>";
}
//Contact Name
if ( $contact == "--" ) {
echo "";
} else {
echo "<tr>";
echo "<td><b>CONTACT NAME</b></td>";
echo "<td>";
echo "$contact";
echo "</td>";
echo "</tr>";
}
//Phone Numbers
if ( $phone1 == "--" ) {
echo"";
} else {
echo "<tr>";
echo "<td><b>PHONE</b></td>";
echo "<td>";
if ( $phone1 == "--" ) {
echo "";
} else {
echo "$phone1";
}
if ( $phone2 == "--" ) {
echo "";
} else {
echo "<br />";
echo "$phone2";
}
if ( $phone3 == "--" ) {
echo "";
} else {
echo "<br />";
echo "$phone3";
}
echo "</td>";
echo "</tr>";
}
//Fax Number
if ( $fax == "--" ) {
echo "";
} else {
echo "<tr>";
echo "<td><b>FAX</b></td>";
echo "<td>";
echo "$fax";
echo "</td>";
echo "</tr>";
}
//Vendor Info
if ( $vendor == "" ) {
echo "";
} else {
echo "<tr>";
echo "<td><b>VENDOR INFO</b></td>";
echo "<td>";
echo "$vendor";
echo "</td>";
echo "</tr>";
}
//END TABLE
echo "</table>";
echo "</p>";
}
?>
as you can see here I'm trying to Get the row "URL" (which is in the database) as the reference instead of "id"