For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > September 2005 > Showing various result from a mysql query









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 Showing various result from a mysql query
Juan Stiller

2005-09-29, 6:56 pm

Hi, im working on a php file that its supposed to
retrieve data from a mysql database, to send it to a
flash animation to show the results. Thing is that im
testing some modifications to the code, so if there is
more than one entry, it shows all the results.

For some reason probably a mistake on the code im
getting this output when i try the muestra.php file on
the browser:

n=1&Hora0=17:30:43&Apellido0=garofalo&Id0=6&Dia0=28&Mes0=9&Ano0=2005&Nombre0=cristian&Destinatario0=martan=1&Hora0=17:30:43&Apellido0=garofalo&Id0=6&Dia0=28&Mes0=9&Ano0=2005&Nombre0=cristian&Receptor0=marilun=1&Hora0=17:30:43&Apellido0=garofalo&Id0=6&Dia0
=28&Mes0=9&Ano0=2005&Nombre0=cristian&Destinatario0=martan=1&Hora0=17:30:43&Apellido0=garofalo&Id0=6&Dia0=28&Mes0=9&Ano0=2005&Nombre0=cristian

This might not be wrong, but when i show info on the
flash animation i get eg:

Apellido0=garofalo , i dont want to get the n=x on the
output, its supposed to be just an internal thing to
tell flash that for the variable Apellido(lastname)
there is more than one result and then to show all of
them.


This is the php code:

<?php
$conn = @mysql_connect("localhost", "blah", "blah23");

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);
?>

Also, i was told that including password and user to
connect to mysql server sholdnīt be shown on the php
file, so i have to use include_one and the file, but i
donīt know exaclty the syntax, can anybody help me
with it?

Thanks in advance.








________________________________________
___________________
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