For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > October 2005 > MySQL query result with some errors!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MySQL query result with some errors!
Juan Stiller

2005-10-11, 6:56 pm

Hi,

Im trying to get a query result from mysql database to
show it on a flash animation, so far i have this code
that its supposed to connect to mysql server , make
the query and get the results, store them on variables
so that flash can read them. Basically i have these
main fileds like : lastname, firstname and so on... a
guy here told me correctly that i should in case to
have more than one entry on the database, use the
output like lastname1, lastname2, etc. I gues this
code is doing that, but when i want to show that info
on flash i get eg:

lastname: smithn=0
lastname: jacksonn=1

when it should be
lastname: smith
lastname: jackson
....
....


So i guess im doing something wrong, can someone point
me in the right direcction??

Here is the php code:

<?php
$conn = @mysql_connect("localhost", "mysql",
"ullneverguessit");

if (!$conn) {
echo( "<P>No se pudo conectar " .
"al servidor MySQL.</P>" );
exit();
}

if (! @mysql_select_db("llamadas") ) {
echo( "<P>No se puede encontrar " .
"la base de datos clientes!</P>" );
exit();
}
////////////////////////////////////////////////////////////////////////////////
$qr = mysql_query("select * from datos");
$nrows =
mysql_num_rows($qr);
$rString = "n=".$nrows;
for ($i=0; $i < $nrows; $i++) {
$row = mysql_fetch_array($qr);
$rstring .= "&Id".$i."=".$row['id'];
$rString .=
"&Dia".$i."=".$row['dia']."&Mes".$i."=".$row['mes']."&Ano".$i."=".$row['ano'];
$rString .=
"&Hora".$i."=".$row['hora']."&Minutos".$i."=".$row['minutos'];
$rString .= "&Receptor".$i."=".$row['receptor'].
$rString .=
"&Destinatario".$i."=".$row['destinatario'].
$rString .= "&Apellido".$i."=".$row['apellido'].
$rstring .= "&Nombre".$i."=".$row['nombre'];
$rstring .= "&Telefono".$i."=".$row['telefono'];
$rstring .= "&Asunto".$i."=".$row['asunto'];
}
echo $rString;
mysql_free_result($qr);
?>

Thanks.
Juan






________________________________________
___________________
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com