Jump to content

Date Formatting within a While Loop array readout...


mikerosenthal

Recommended Posts

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_entry
to 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

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.