Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: RE: to all and to Adam Lang, Nate ,problem with a


Message #1 by Info <info@d...> on Thu, 22 Mar 2001 21:47:35 -0600
Jorge,

Try this:

// this will print a message in case there is no record found
with the client input
if(mysql_num_rows($qcan)==0){
echo("No se encontro nada con ese criterio de busqueda same as no
result found");
exit();
}

mysql_num_rows returns the number of rows in a result set. So, this code
will print the "no records found" message if there are 0 rows.

Good luck!

Nate LaClaire

--------------------------------
Netwalker Internet Services
http://www.netwalkerinternet.com
--------------------------------



> -----Original Message-----
> From: Info [mailto:info@d...]
> Sent: Thursday, March 22, 2001 10:48 PM
> To: nnetwalker@h...
> Subject: [pro_php] RE: to all and to Adam Lang, Nate ,problem with a
>
>
> my problem now comes to this if i make to calls is becuase when
> they search the list and ther is nothing i needt to fetch a
> result so if result is empty i can print the message no records
> with the info you have requested
> I was doing this through two set of mysql_fetch_array what would
> happen if i used one mysql_fetch_ row and one mysql_fetch_ array
> will this produce the same problem
> here is copy of my code
>
> if(!($qcan=mysql_query("SELECT * FROM albums where autor like
> '$autor%'"))){
> echo("Error 001"."".mysql_error());
> exit();
> }
> // this will print a message in case there is no record found
> with the client input
> if(!($rqcan=mysql_fetch_array($qcan)){
> echo("No se encontro nada con ese criterio de busqueda same as no
> result found");
> exit();
> }
> // this is to print the results if foud any
> while($rqcan=mysql_fetch_array($qcan)){
>     echo("<tr>");
>       echo("<td width='5%'>"."<div align='center'>"."<font
> size='2'>".$rqcan["id_num"]."</font>"."</div>"."</td>");
>    echo("<td width='5%'>"."<div align='center'>"."<font
> face='Arial
> Black'size='2'>".$rqcan["disco_num"]."</font>"."</div>"."</td>");
>    echo("<td width='5%'>"."<div align='center'>"."<font
> size='2'>".$rqcan["cancion_num"]."</font>"."</div>"."</td>");
>    echo("<td width='25%'>"."<div align='left'>"."<font
> face='Arial Black'size='2'>".$rqcan["titulo"]."</font>"."</div>"."</td>");
>       echo("<td width='20%'>"."<div align='left'>"."<font
> size='2'>".$rqcan["autor"]."</font>"."</div>"."</td>");
>       echo("<td width='20%'>"."<div align='left'>"."<font
> size='2'>".$rqcan["interprete"]."</font>"."</div>"."</td>");
>       echo("<td width='20%'>"."<div align='center'>"."<font
> size='2'>".$rqcan["genero"]."</font>"."</div>"."</td>");
> echo("</tr>");
> }
> ?>
> solve the problem with a do while loop but iam not real happy
> about it. like this
>
> if(!($qcan=mysql_query("SELECT * FROM albums where autor like
> '$autor%'"))){
> echo("Error 001"."".mysql_error());
> exit();
> }
> // this will print a message in case there is no record found
> with the client input
> if(!($rqcan=mysql_fetch_array($qcan)){
> echo("No se encontro nada con ese criterio de busqueda same as no
> result found");
> exit();
> }
> // this is to print the results if foud any
> do{
>     echo("<tr>");
>       echo("<td width='5%'>"."<div align='center'>"."<font
> size='2'>".$rqcan["id_num"]."</font>"."</div>"."</td>");
>    echo("<td width='5%'>"."<div align='center'>"."<font
> face='Arial
> Black'size='2'>".$rqcan["disco_num"]."</font>"."</div>"."</td>");
>    echo("<td width='5%'>"."<div align='center'>"."<font
> size='2'>".$rqcan["cancion_num"]."</font>"."</div>"."</td>");
>    echo("<td width='25%'>"."<div align='left'>"."<font
> face='Arial Black'size='2'>".$rqcan["titulo"]."</font>"."</div>"."</td>");
>       echo("<td width='20%'>"."<div align='left'>"."<font
> size='2'>".$rqcan["autor"]."</font>"."</div>"."</td>");
>       echo("<td width='20%'>"."<div align='left'>"."<font
> size='2'>".$rqcan["interprete"]."</font>"."</div>"."</td>");
>       echo("<td width='20%'>"."<div align='center'>"."<font
> size='2'>".$rqcan["genero"]."</font>"."</div>"."</td>");
> echo("</tr>");
> }while($rqcan=mysql_fetch_array($qcan));
> ?>
>
>
>
>
>
>
>
> ----- Original Message -----
> From: Nate LaClaire <nate@m...>
> To: professional php <pro_php@p...>
> Sent: Jueves, 22 de Marzo de 2001 12:35 p.m.
> Subject: [pro_php] RE: to all and to Adam Lang problem with a
>
>
> > Jorge,
> >
> > The only thing that I can think of that would cause this
> problem is having
> > "$result=mysql_fetch array($query);" somewhere above your while
> loop. This
> > would cause the first record to be placed into $result and then
> be replaced
> > by the second record when your while loop is invoked. You don't
> have a line
> > like that above the while loop, do you?
> >
> > Nate LaClaire
> >
> > ---------------------------------
> > Netwalker Internet Services
> > http://www.netwalkerinternet.com/
> > ---------------------------------
> >
> >
> > -----Original Message-----
> > From: Info [mailto:info@d...]
> > Sent: Thursday, March 22, 2001 11:17 AM
> > To: nnetwalker@h...
> > Subject: [pro_php] to all and to Adam Lang problem with a
> >
> >
> > I solve the problem like this but It seems sopmething wrong
> > i wa using a while loop
> > like this
> > while($result=mysql_fetch array($query)){
> > print all the results.....an the first result of the set was missing
> > }
> > now I am doing a do while loop
> > do{
> > print the results}while($result=mysql_fetch array($query));this prints
> > everything fine;
> > why is this hapening i now that the do while loop get executed
> at least one
> > time but why the while loop doesnt show the first result or the
> query??? It
> > mus show it right??
> >
> > ----- Original Message -----
> > From: Jorge Cordero <jorge@d...>
> > To: professional php <pro_php@p...>
> > Sent: Miércoles, 21 de Marzo de 2001 04:36 p.m.
> > Subject: [pro_php] when querying a data base mysql_fecth_array
> jumps the 1st
> > record???
> >
> >
> > > I ha ve a database  with cd music albums
> > > author ,title, group, cd_number, and song_num also there is an auto
> > > increment id_num column.
> > > if i query the data base through my web page on the cd_number
> the first
> > song
> > > of  the cd never shows.
> > > but when query by any of the other fields everything is perfect.
> > > if i query directly on the server through telnet all of them are fine
> > > my query is so simple that cant see why this is happening
> > >
> > > $query=mysql_query("SELECT * FROM tablename WHERE
> cd_num=$cd_num order by
> > > song_num");
> > > this is the same query I am using for everything else the
> only change is
> > the
> > > WHERE clause.
> > >
> > > to extract the result I am using
> > >
> > > while($result=mysql_fetch_array($query)){
> > > results here (html table)
> > > }
> > > This have never happened before so if some out there knows
> whats going on
> > >
> > > Thanks for your help
> > >
> > > Jorge


  Return to Index