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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.