A quick glance says that's all perfectly right, I would run the query on the mysql
command line to be sure it's really giving more than 1 result - but I can suggest two
things:
1) be sure to mysql_free_result($result) afterwards if you're done with the query but
your script will still be doing anything. You really do want to do that because it
tells mysql you're done with that so it can release the memory - PHP doesn't actually
use the memory for that resultset, it just holds a result id that it uses to get the
results from mysql (so best to let mysql have its memory back as soon as you're done).
2) you will save yourself a fair amount of effort and readability, if you don't need
those variables other than to print, to change things like so:
---------------
$apellido=$row["apellidoclientesnuevos"];
echo "&Apellido=$apellido";
--- becomes ---
echo "&Apellido={$row['appellidoclientesnuevos']}";
---------------
(you don't need to use ', " works too - I find ' more legible here)
This may also reduce confusion if you start thinking that the database field is
holding just names, instead of names of new clients (e.g. you accidentally paste it
elsewhere for use and keep pulling only from the new clients table).
Are you perhaps storing clients in that table temporarily, so it rarely has many
clients in it? That could explain the behaviour as well.
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent those of St.
Jude Children's Research Hospital.
-----Original Message-----
From: Juan Stiller [mailto:[EMAIL PROTECTED]
Sent: Monday, October 18, 2004 11:07 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Showing all mysql query results!
Hi, im using this script, to show all entrys of a
mysql database on a flash movieclip, but i was told at
flash forums, that this code is not ok, because its
showing only the last entry not all of them, maybe you
someone can recommend what to add to this little
script?.
<?php
$conn = @mysql_connect("***", "***", "****");
if (!$conn) {
echo( "<P>No se pudo conectar " .
"al servidor MySQL.</P>" );
exit();
}
if (! @mysql_select_db("clientes") ) {
echo( "<P>No se puede encontrar " .
"la base de datos clientes!</P>" );
exit();
}
// Request all data
$result1 = mysql_query("select * from
clientesnuevos");
print "Results=";
echo "<h1>Clientes agregados:</h1><br>";
while($row=mysql_fetch_array($result1, MYSQL_ASSOC))
{
$id=$row["id"];
echo "&Id=$id";
$apellido=$row["apellidoclientesnuevos"];
echo "&Apellido=$apellido";
$nombre=$row["nombreclientesnuevos"];
echo "&Nombre=$nombre";
$dni=$row["dniclientesnuevos"];
echo "&Dni=$dni";
$telefono=$row["telefonoclientesnuevos"];
echo "&Telefono=$telefono";
$dia=$row["diacitaclientesnuevos"];
echo "&Dia=$dia";
$mes=$row["mescitaclientesnuevos"];
echo "&Mes=$mes";
$ano=$row["anocitaclientesnuevos"];
echo "&Ano=$ano";
$hora=$row["horacitaclientesnuevos"];
echo "&Hora=$hora";
$minutos=$row["minutoscitaclientesnuevos"];
echo "&Minutos=$minutos";
$abogado=$row["abogadoclientesnuevos"];
echo "&Abogado=$abogado";
$asunto=$row["asuntoclientesnuevos"];
echo "&Asunto=$asunto";
$donde=$row["dondeclientesnuevos"];
echo "&Donde=$donde";
}
?>
Thanks
Emilio
___________________________________
�Llevate a Yahoo! en tu Unif�n!
Ahora pod�s usar Yahoo! Messenger en tu Unif�n, en cualquier momento y lugar.
Encontr� m�s informaci�n en: http://ar.mobile.yahoo.com/sms.html
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php