Jump to content

[SOLVED] Inserting Time


cheechm

Recommended Posts

oh rite then

 

instead of using the code i gave you earlier, use this:

 

<?php

// Your form code

if($_POST)
{

$date = date('YmdHia');

$query = "INSERT INTO Results (Date)
VALUES('$date')";

mysql_query($query) or die(mysql_error());

}

?>

 

and

 

<?php
$query = mysql_query("SELECT Date FROM Results"); // You will most likely need a WHERE statements
$row = mysql_fetch_array($query) or die(mysql_error());
$date = $row['Date'];

list ($date,$time) = explode(' ',$date);

list ($year,$month,$day) = explode('-',$date);
$date = "$day/$month/$year";

echo "$date $time";
?>

 

I hope that works,

 

~ Chocopi

I've changed a few things, so use all of the code below

 

Try this then:

 

<?php

$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$time = $_POST['time'];
$date = $year.''.$month.''.$day.''.$time;

?>

<form action="addevent.php" method="post">
Event Name: <input type="text" name="eventname" /><br />
Yeargroup: <input type="text" name="year" /><br />
Team: <br /><textarea rows="3" cols="30" name="team" /></textarea><br />
Date (DD/MM/YYYY): 
<input type="text" name="day"  onfocus="this.value=''" value="Day"/>
<input type="text" name="month"  onfocus="this.value=''" value="Month"/>
<select name="year">
<option value="2007">2007</option>
<option value="2008">2008</option>
</select>
<select name="time">
<option value="123000">12:30</option>
<option value="games">During games period</option>
<option value="160000">4:00</option>
</select>


<input type="submit" value="Add Event"/>
</form>

<?php

if($_POST)
{

$query = "INSERT INTO Results (Date)
VALUES('$date')";

mysql_query($query) or die(mysql_error());

?>

 

Hope it works right  ;D

 

~ Chocopi

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.