hi. i store dates in a table called concert_calendar. i'm trying to use the sql function, format_date and format_time to retrieve the fields formatted for display. the date and time are correctly formatted, but the date and time from the first row returned is displayed for all records. i'm having trouble solving this. do i need a foreach statement somehow? thanks for your help
--brian
//query table using sql date_format and time_format to get dates and times in correct fromat for display
$result_date = mysql_query("SELECT date_format(date,'%M %e %Y') AS date from concert_calendar");
$myrow_date = mysql_fetch_array($result_date);
$result_time = mysql_query("SELECT time_format(time,'%l:%i %p') AS time from concert_calendar");
$myrow_time = mysql_fetch_array($result_time);
//now get all the other fields from the table and order them by date
$result = mysql_query("SELECT * FROM concert_calendar ORDER BY date",$db);
//if there are records, then diplay them in an html table
if ($myrow = mysql_fetch_array($result)) {
echo "<table border=1 bordercolor=\"333333\" cellspacing=\"2\" cellpadding=\"2\">\n";
do {
printf("<tr bgcolor=\"cccccc\"><td><font color=\"#003399\" size=\"3\" face=\"Arial, Helvetica, sans-serif\"><strong>Date/Time</strong></font>\n</td>");
printf("<td><font color=\"#003399\" size=\"3\" face=\"Arial, Helvetica, sans-serif\"><strong>Location</strong></font>\n</td>");
printf("<td><font color=\"#003399\" size=\"3\" face=\"Arial, Helvetica, sans-serif\"><strong>Telephone</strong></td></tr></font>\n");
printf("<tr><td><font color=\"#003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">%s %s</td>\n", $myrow_date["date"], $myrow_time["time"]);
printf("<td><a href=\"#\" onclick=\"window.open('http://%s', '','width=500,height=500');\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\">%s</font></a> ", $myrow["location_url"], $myrow["location"]);
printf("<a href=\"#\" onclick=\"window.open('http://www.mapquest.com/maps/map.adp?adress=%s&city=%s&state=%s&zipcode=%s&country=US&cid=lfmaplink', '','width=500,height=500');\"><font font color=\"#993300\"size=\"2\" face=\"Arial, Helvetica, sans-serif\">Map</font></a>", $myrow["street"], $myrow["city"], $myrow["state"], $myrow["zip"]);
printf("<font color=\"#003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\"><br>%s<br>%s, %s %s</font>", $myrow["street"], $myrow["city"], $myrow["state"], $myrow["zip"]);
printf("<font color=\"#003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\"><br>%s</font></td></font>\n", $myrow["other"]);
printf("<td><font color=\"#003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">%s</font></td></tr></font>\n", $myrow["phone"]);
printf("<tr><td colspan=\"3\"><font color=\"#003399\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">%s</td><td></tr></font>\n", $myrow["description"]);
} while ($myrow = mysql_fetch_array($result));
echo "</table>\n";
} else {
//if no records, display error message
echo "Sorry, no records were found!";
}