Hello...
Newbie needs help.
I've got a script that runs a query on a database and returns event information. The script will display the data in a table with three cells (Event, Date, Venue). I've recently added a split and switch() functions so that I may redisplay the date in a "Month Name, Day, Year" format (but in Spanish) from the YYYY-MM-DD format. I have to take the month number and redisplay it as a Month Name.
My problem is that when I add the function after a:
while ($row = mysql_fetch_array($result))
The function works as expected and displays the new formatted date in its proper cell in the table. But with empty event and venue cells, even though there is valid data returned from the query.
If I place the two functions before the while function, I get proper event and venue information but no date information.
Following is the code snippet. Any help would be immensely appreciated.
---------code------------------
<?PHP
$db = mysql_connect("localhost", "me", "me");
if( !$db )
{
die("Error connecting to the Server");
exit;
}
$result = mysql_select_db("concerts", $db);
if( !$result )
{
die("Error selecting Database");
exit;
}
$query = " SELECT
concert_schedule.evento, concert_schedule.grupo, concert_schedule.fecha, concert_schedule.invitados, venues.ciudad, venues.pais,
venues.local, venues.direccion, venues.estado, venues.zip, venues.phone, venues.direc2, venues.email, venues.URL
FROM concert_schedule, venues
WHERE concert_schedule.fecha=\"$mifecha\" and venues.local=concert_schedule.local
ORDER BY concert_schedule.grupo AND fecha ASC";
$result = mysql_query($query,$db);
if( !$result )
{
die("Error executing query");
}
echo "<tr height=35>";
echo "<td width=250 align=CENTER bgcolor='#000000'><font face='Arial' size='2' color='#FFFFFF'><b>Evento <br> Artista e Invitados</b></font></td>";
echo "<td align=CENTER bgcolor='#000000'><font face='Arial' size='2' color='#FFFFFF'><b>Fecha</b></font></td>";
echo "<td align=CENTER bgcolor='#000000'><font face='Arial' size='2' color='#FFFFFF'><b>Local</b></font></td>";
echo "</tr>";
{
while ($row = mysql_fetch_array($result))
$rompe = split('-', $row[fecha]);
$dia = $rompe[2];
$anio = $rompe[0];
switch($rompe[1])
{
case "01":
$mes = "Enero";
break;
case "02":
$mes = "Febrero";
break;
case "03":
$mes = "Marzo";
break;
case "04":
$mes = "Abril";
break;
default:
$espfecha=$row[fecha];
}
$espfecha = "$mes $dia, $anio";
printf("
<tr height=35>
<!---Artista e Invitados -->
<td width=250 align=left valign=top>
<table>
<tr>
<td width=250 valign=top><font face=verdana size=2><b><i>%s</i></b></font></td>
</tr>
<tr>
<td><font face=verdana size=1><b>%s</b><br>%s</font></td>
</tr>
</table>
</td>
<!--- Fecha -->
<td align=left valign=top><font face=verdana size=1>%s</font></td>
<!--- Local -->
<td align=left valign=top><font face=verdana size=1><b>%s</b><br> %s<br>%s<br>%s %s<br> %s %s<br>%s<br>
Web: <a href=\"http://%s</a> <br>
Email: <a href=\"mailto:%s\">%s</a> </center> </font></td></font></td>
<!--- Pagina -->
</tr>\n",$row[evento],$row[grupo],$row[invitados],$espfecha,$row[local],$row[direccion],$row[direc2],$row[ciudad],$row[estado],$row[zip],$row[pais],$row[phon
e],$row[URL],$row[email],$row[email]);
$AffectedRows = mysql_affected_rows($db);
print("<font size=2 face='verdana, helvetica'><b> Encontramos <font size=+2> $AffectedRows </font> conciertos para $espfecha.</b></font><br><br>\n");
}
?>