mySQL date() and user input.

Codes here !

Moderators: macek, egami, gesf

Johnny010
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Sep 17, 2012 6:28 am

mySQL date() and user input.

Postby Johnny010 » Tue Sep 18, 2012 9:13 am

Hey. I have made a site which uses a mySQL table with a column 'time' with the values formed from:

date_default_timezone_set("UTC");
$UTCDT = date("Y-m-d H:i:s", time());


Where $UTCDT is inserted in to the table.

This is great of course, as I have essentially made a timestamp for when information was inserted in to the table.

But...here is the but...

I want to have the ability for a user to view the data between 2 times of their choice. What is the best way to go about this? Is there a way to make the following (once it has been sent to a second .php via $_POST and stored as $variables translate in to the date/time format I have selected. I would then use the variables to form a mysql select where between _____ AND ______ type jobby. Thanks :)

Code: Select all

echo "Select date range start :";
echo "<select name=\"day\">";
$i="";
while ($i<31){ echo "<option value=".$i.">".$i."</option>"; $i++;}

echo"</select>";

echo "<select name=\"month\">";

$i="";
while ($i<13){ echo "<option value=".$i.">".$i."</option>"; $i++;}
echo"</select>";

echo " Year: <input type=\"text\" name=\"year\">";

echo "End :";
echo "<select name=\"endday\">";
$i="";
while ($i<31){ echo "<option value=".$i.">".$i."</option>"; $i++;}

echo"</select>";

echo "<select name=\"endmonth\">";

$i="";
while ($i<13){ echo "<option value=".$i.">".$i."</option>"; $i++;}
echo"</select>";

echo " Year: <input type=\"text\" name=\"endyear\">";

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron