chocopi Posted June 9, 2007 Share Posted June 9, 2007 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 Quote Link to comment Share on other sites More sharing options...
cheechm Posted June 9, 2007 Author Share Posted June 9, 2007 Doing that outputs 00/00/0000 00:00:00 I think it is something to do with the form. Quote Link to comment Share on other sites More sharing options...
chocopi Posted June 9, 2007 Share Posted June 9, 2007 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 ~ Chocopi Quote Link to comment Share on other sites More sharing options...
cheechm Posted June 9, 2007 Author Share Posted June 9, 2007 Thanks for all the hard work. Works perfectly. Quote Link to comment Share on other sites More sharing options...
chocopi Posted June 9, 2007 Share Posted June 9, 2007 Excellent, I'm so relieved as I don't usually deal with time and dates, so I'm glad it's sorted Happy Coding, ~ Chocopi Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.