Hi I am making a website for events and I wanted to display the date from the database..
if i jus retrive the date as it is the query is working..
Now if I want my date to be printed as Sunday 12th January 2013, I run the query given below and it works jus fine in mysql but wen i run it thro my webpage its not happening...
d_o_e is my date of event column name.
$sqldate="SELECT DATE_FORMAT(d_o_e, '%W %D %M %Y')FROM events WHERE event_id=$event_id;";
$result=mysqli_query($connect_db,$sqldate);
$rowdate=mysqli_fetch_array($result);
$dateformat=$rowdate["d_o_e"];
How should I go abt it? How to hold the value returned by the query?? Thanks in advance
Consider using alias
$sqldate="SELECT DATE_FORMAT(d_o_e, '%W %D %M %Y' ) as `d_o_e` FROM events WHERE event_id=$event_id;";
whne you ran your query the column name you are getting is DATE_FORMAT(d_o_e, '%W %D %M %Y' )
and not d_o_e
. So use alias to make it simpler.
If you enable the error reporting you must be getting undefined index error
for your code .
Hope you got what I meant .
DATE_FORMAT is a mysql function and you should assign variable name for result, such as:
$sqldate="SELECT DATE_FORMAT(d_o_e, '%W %D %M %Y') as formatted_date FROM events WHERE event_id=$event_id;";
and then use like $dateformat=$rowdate["formatted_date"];