fogofogo Posted June 2, 2006 Share Posted June 2, 2006 Hi folks, I have a form that submits a date in this format : June 2006, and I am trying to use it to select records in a mysql database, that stores the date in this format: 2006-06-01.So I must change June 2006 into 2006-06-01 and then feed it into the feed the date into the SQL statement - right?? This is the part I am stuck on.some thing like this? $formattedDate = date("F Y", strtotime($month)); my code so far (which is probably way off), looks like this...[code]<?php// print out the month that has been choosen$month = $_POST['date'];echo $month;//$formattedDate = date("F Y", strtotime($month)); ...database stuff...$query = mysql_query("SELECT DISTINCT ddate, DATE_FORMAT(ddate, '%Y %M') ID FROM pokercredit"); // print out the recordswhile ($row = mysql_fetch_array($query)){echo "$row[ID] $row[dfrom] $row[damount]<br>"; // name class and mark will be printed with one line break at the end}?>[/code]I'm obviously way off but any advice would be great, as I'm totally stuck on this.Thanks allJ Link to comment https://forums.phpfreaks.com/topic/11014-phpsql-problem/ Share on other sites More sharing options...
fogofogo Posted June 2, 2006 Author Share Posted June 2, 2006 fixed it - if anyone would like to see the code:[code]<?php// print out the month that has been choosen$month = $_POST['date'];echo $month;include("db.php");// select the ddate //echo "SELECT * FROM pokercredit WHERE DATE_FORMAT(ddate, '%Y %M')='.$month;$query = mysql_query("SELECT * FROM pokercredit WHERE DATE_FORMAT(ddate, '%Y %M')='".$month."'"); // print out the recordswhile ($row = mysql_fetch_array($query)){echo "$row[ID] $row[dfrom] $row[damount]<br>"; // name class and mark will be printed with one line break at the end}?>[/code]it might be messy, but it works! Link to comment https://forums.phpfreaks.com/topic/11014-phpsql-problem/#findComment-41158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.