Ver Mensaje Individual
  #16 (permalink)  
Antiguo 20/02/2003, 10:36
Cluster
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Si has aplicado una funcion a un campo de tu consulta SQL .. tienes dos opciones para acceder al valor resultante de aplicar dicha función:

Accediendo por el indice numerico .. (no por el indice asociativo).
Código PHP:
$result=mysql_db_query("aviso","select max(id) from aviso_tradicional");

while (
$row=mysql_fetch_array($result))
{
echo 
'<tr align="left" valign="top"><td><font size="2" face="Geneva, Arial, Helvetica, san-serif">'.$row[0].'</font></td>';
}
mysql_free_result($result
Haciendo un alias de la funcion .. y accediendo por su indice asociativo:
Código PHP:
$result=mysql_db_query("aviso","select max(id) as maximo from aviso_tradicional");

while (
$row=mysql_fetch_array($result))
{
echo 
'<tr align="left" valign="top"><td><font size="2" face="Geneva, Arial, Helvetica, san-serif">'.$row['maximo'].'</font></td>';
}
mysql_free_result($result
Otro detalles es que ese max() solo va a entregarte UN solo registro con el valor del campo id maximo .. Por lo tanto puedes eliminar completametne el bucle while y quedarte con solo el $row=mysql_fetch_array($result) .. o bien usar simplemente:

Código PHP:
mysql_result($result,0); 
O si usas el alias

Código PHP:
mysql_result($result,0,"maximo"); 
Un saludo,