Please try to bear with me, I'm a newbie at PHP. I have a form here that will be submitted to a PHP page and from there submitted to a table in a database and finally shows the submitted information in a table. I need help sorting the table by columns and filling in one field.
Here's my form:
What I want is when the user submits the form, convert the time selected by the user, based on user's current time, to Central Time. (Example: If 5:00 P.M. is selected by user and the user is Eastern Time, then the converted time would be 4:00 P.M.) Since this form will be used around the world, it's better to have just 1 time zone rather than 24 different time zones.
Here is the form submission data:
(The header location is not the one I'm using but I rather not reveal the location.) This will insert information into the "schedule" table in my database. There is a 4th field that is not shown, countdown, in the table.
Here is the table database:
I want the countdown field to be automatically calculated by taking the difference of the user's time by the time in the table. (Example: 3 days, 8 hours, 4 minutes left) Also, I want the table to be sorted when the <th> text is clicked. Any help would be greatly appreciated. Thanks.
Here's my form:
PHP:
<?php
$tournamenttype = array (1 => 'Point Tournament','Bounty Tournament','Jacks Tournament','Team Tournament');
$numberofseats = array (1 => '4 Seats','5 Seats','6 Seats','7 Seats','8 Seats','9 Seats','10 Seats','11 Seats');
$buyin = array (1 => '$500','$1,000','$1,500','$2,000','$2,500','$3,000','$3,500','$4,500','$5,000','$6,000','$7,000','$8,000','$9,000','$10,000','$15,000','$20,000','$25,000','$30,000','$40,000','$50,000','$60,000','$70,000','$80,000','$90,000','$100,000','$125,000','$150,000','$175,000','$200,000');
$month = array (1 => 'January','February','March','April','May','June','July','August','September','October','November','December');
$day = array (1 => '1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
$year = array (1 => '2010', '2011');
$hour = array (1 => '1','2','3','4','5','6','7','8','9','10','11','12');
$minute = array (1 => '00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60');
$ampm = array (1 => 'A.M.', 'P.M.');
echo '<div><form method="post" action="newevent.php"><input type="hidden" name="submitted" value="true" /><fieldset><legend>Setup</legend><select name="tournamenttype"><optgroup label="Tournament Type">';
foreach ($tournamenttype as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select>';
echo '<select name="numberofseats"><optgroup label="Number of Seats">';
foreach ($numberofseats as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select>';
echo '<select name="buyin"><optgroup label="Buyin">';
foreach ($buyin as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select></fieldset>';
echo '<fieldset><legend>Date</legend><select name="month"><optgroup label="Month">';
foreach ($month as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select>';
echo '<select name="day"><optgroup label="Day">';
foreach ($day as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select>';
echo '<select name="year"><optgroup label="Year">';
foreach ($year as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select></fieldset>';
echo '<fieldset><legend>Time</legend><select name="hour"><optgroup label="Hour">';
foreach ($hour as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select>';
echo '<select name="minute"><optgroup label="Minute">';
foreach ($minute as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select>';
echo '<select name="ampm"><optgroup label="A.M. or P.M.">';
foreach ($ampm as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; }
echo '</optgroup></select>';
echo '<input type="submit" value="Create Event" /> <input type="reset" value="Reset Fields" />';
echo '</fieldset></form></div>';
?>
What I want is when the user submits the form, convert the time selected by the user, based on user's current time, to Central Time. (Example: If 5:00 P.M. is selected by user and the user is Eastern Time, then the converted time would be 4:00 P.M.) Since this form will be used around the world, it's better to have just 1 time zone rather than 24 different time zones.
Here is the form submission data:
PHP:
<?php
if (isset($_POST['submitted']))
{
include('shared/mysqlconnect.php');
$setup = $_POST['tournamenttype'] . "," . " " .$_POST['numberofseats'] . "," . " " . $_POST['buyin'];
$date = $_POST['month'] . " " . $_POST['day'] . "," . " " . $_POST['year'];
$time = $_POST['hour'] . ":" . $_POST['minute'] . " " . $_POST['ampm'];
$sqlinsert = "INSERT INTO schedule (setup, date, time) VALUES ('$setup', '$date', '$time')";
if (!mysqli_query($dbcon, $sqlinsert))
{
die("Event could not be added. Click the back button and try again.");
}
else
{
header("location:http://www.x10hosting.com/");
}
}
?>
(The header location is not the one I'm using but I rather not reveal the location.) This will insert information into the "schedule" table in my database. There is a 4th field that is not shown, countdown, in the table.
Here is the table database:
PHP:
<?php
include('shared/mysqlconnect.php');
$sqlget = "SELECT * FROM schedule ORDER BY date, time";
$sqldata = mysqli_query($dbcon, $sqlget) or die('Database Connection Failed.');
echo '<table class="innertable"><tr><th class="scheduleheader">Setup</th><th class="scheduleheader">Date</th><th class="scheduleheader">Time</th><th class="scheduleheader">Countdown</th></tr>';
while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) { echo '<tr><td class="data">';
echo $row['setup'];
echo '</td><td class="data">';
echo $row['date'];
echo '</td><td class="data">';
echo $row['time'];
echo '</td><td class="data">';
echo $row['countdown'];
echo '</td></tr>'; }
echo '</table>';
?>
I want the countdown field to be automatically calculated by taking the difference of the user's time by the time in the table. (Example: 3 days, 8 hours, 4 minutes left) Also, I want the table to be sorted when the <th> text is clicked. Any help would be greatly appreciated. Thanks.
Last edited: