mikerosenthal Posted September 15, 2006 Share Posted September 15, 2006 im sure the subject of this post gives me away as a total newbee...i have been trying all night to solve this seemingly simple problem. Basically i am needing to format data being read out of a mysql database with php. It is an event listing script, where it reads through a table, pulls out each event, and displays the date, time, name of the event. i need to have the date formatted in a certain way (ideally Day of Week, Date#, Month, but whatever...) which seems really straightforward. here is my script: <?$q = "SELECT * FROM webcal_entry ORDER by cal_date"; $r = mysql_query($q); while ($a = mysql_fetch_array($r)) { print ("$a[date_test] $a[cal_name] $a[cal_time]pm");}?>basically i dont know how to apply this:SELECT date_format(date_test, '%a %D %b %Y') as formatted_date from webcal_entryto each entry in the array. hm. im not sure im asking this question in a clear way. does this make any sense? im able to get it to do what i need when my script is just this:<?php$q = "SELECT date_format(date_test, '%a %D %b %Y') as formatted_date from webcal_entry;"; $r = mysql_query($q); while ($a = mysql_fetch_array($r)) { print ("$a[formatted_date]");}?>but i need it happening as its looping through all the events in my table. surely this is easy...can anyone help?-mike Quote Link to comment Share on other sites More sharing options...
btherl Posted September 15, 2006 Share Posted September 15, 2006 You can do[code]SELECT date_format(date_test, '%a %D %b %Y') as formatted_date, cal_name, cal_time from webcal_entry[/code]It's good coding practice to specify which columns you want in a SELECT too. Quote Link to comment Share on other sites More sharing options...
mikerosenthal Posted September 15, 2006 Author Share Posted September 15, 2006 nice. thanks. knew it had to be simple. and thanks for the tip about columns too!just getting started... 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.