Skip to content

Instantly share code, notes, and snippets.

@samsmo
Created April 9, 2012 19:25
Show Gist options
  • Save samsmo/2345869 to your computer and use it in GitHub Desktop.
Save samsmo/2345869 to your computer and use it in GitHub Desktop.
myFair
<?php
require_once('mobile_device_detect.php');
mobile_device_detect(true,true,true,true,true,true,true,'http://mynysfair.com/mobile',false);
if (!isset($_SESSION)) {
session_start();
}
$logininfo .='';
if (!(isset($_SESSION['MM_Username']))){
$logininfo .='<td>
<h2>Login</h2><br /><a href="login.php">Click here to login</a>
</td>
<td>
<h2>Register</h2>
<a href="register.php">Click here to register</a>
</td>';
}
else{
$logininfo .= '<td>
Your Logged in.
</td>
<td>
<h2>Save</h2>
<a href="saveInfo.php">Click here to save your choices</a>
</td>';
}
$arrChoice = $_SESSION['myChoices'];
$date = $_SESSION['Date'];
$query ="SELECT `id`,`Attraction`,`Location`,`Description`,`Start Time`,`End Time`,`All Day` FROM `fair_event_table` WHERE ";
$username='***';
$password='***';
$database='***';
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
//mysql select query
$counter=0;
if((isset($_SESSION['myChoices']))){
foreach($arrChoice as $choice){
if($counter<1){
$query .= "`id` ='".$choice."'";
}else{
$query .= " OR `id` ='".$choice."'";
}
$counter++;
}
}
$result = mysql_query($query);
if(!$result) {
echo mysql_error();
}
$content ='<h2>Attractions:</h2>';
$content .='<form><table>';
while(($resultArray[] = mysql_fetch_assoc($result)) || array_pop($resultArray));
function loopy($time,$array,$allDay){
$myStuff .='';
$myStuff .='<table>';
foreach($array as $event){
global $choiceString;
if($event['Start Time'] == $time && $event['All Day'] == '0' && !$allDay){
$myStuff .= "<tr><td>".$event['Attraction']."</td><td> ".$event['Description']."</td><td>".DATE("g:i a", STRTOTIME($event['Start Time']))." - ".DATE("g:i a", STRTOTIME($event['End Time']))."</td><td>".$event['Location']."</td></tr>";
}else if($event['All Day'] == '1' && $allDay){
$myStuff .= "<tr><td>".$event['Attraction']."</td><td> ".$event['Description']."</td><td>".DATE("g:i a", STRTOTIME($event['Start Time']))." - ".DATE("g:i a", STRTOTIME($event['End Time']))."</td><td>".$event['Location']."</td></tr>";
}
}
$myStuff .='</table>';
echo $myStuff;
}
mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>
Finalize Your Data
</title>
</head>
<body>
<h1>myFair</h1>
<p>Phasellus fermentum fermentum lacus rutrum mollis. Nam sem ligula, faucibus eget scelerisque et, sagittis feugiat urna. Duis dapibus scelerisque metus non lacinia. Mauris pretium sodales nunc sit amet auctor. Cras dignissim elit eget nisi vehicula tincidunt. Nullam vel purus sapien, sit amet rutrum lectus. Praesent tincidunt scelerisque adipiscing. Vivamus a turpis ac ipsum euismod tincidunt vitae ut tortor. Donec nec risus tellus. Nam volutpat aliquet ante et tincidunt. Nulla sed mi a leo venenatis ullamcorper. Aliquam vel lectus risus. Suspendisse nunc metus, lobortis sit amet porta ut, laoreet id metus. Morbi semper laoreet dignissim. Pellentesque vitae dolor purus.</p>
<h3>Plan Your Day:</h3>
<h4> <?php echo $date; ?> </h4>
<table>
<tr>
<td>
<h4>All Day</h4>
<?php loopy('08:00:00',$resultArray, 1);?>
</td>
</tr>
<tr>
<td>
<h4>8:00 AM</h4>
<?php loopy('08:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>9:00 AM</h4>
<?php loopy('09:00:00',$resultArray, 0); ?>
</td>
</tr>
<tr>
<td>
<h4>10:00 AM</h4>
<?php loopy('10:00:00',$resultArray, 0); ?>
</td>
</tr>
<tr>
<td>
<h4>11:00 AM</h4>
<?php loopy('11:00:00',$resultArray, 0); ?>
</td>
</tr>
<tr>
<td>
<h4>12:00 PM</h4>
<?php loopy('12:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>1:00 PM</h4>
<?php loopy('13:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>2:00 PM</h4>
<?php loopy('14:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>3:00 PM</h4>
<?php loopy('15:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>4:00 PM</h4>
<?php loopy('16:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>5:00 PM</h4>
<?php loopy('17:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>6:00 PM</h4>
<?php loopy('18:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>7:00 PM</h4>
<?php loopy('19:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>8:00 PM</h4>
<?php loopy('20:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>9:00 PM</h4>
<?php loopy('21:00:00',$resultArray, 0);?>
</td>
</tr>
<tr>
<td>
<h4>10:00 PM</h4>
<table>
<tr>
<td><h4>GATES CLOSED</h4>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table>
<tr>
<?php echo $logininfo;?>
</tr>
</table
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment