Re: Re: can't get printf() to work
| From: | Gary | Date: | Sun, 29 Oct 2000 15:37:51 +0000 |
| Subject: | Re: Re: can't get printf() to work | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22553@lists.php.net to get a copy of this message | ||
Michael wrote:
> On Sat, 28 Oct 2000, Gary wrote:
>
> > gives me the correct result. Here is the latest variation of what i am
> > using. The echo table cells works fine, not the printf.
> >
> > while ($myrow=mysql_fetch_array($result));
> >
>
> If that's a verbatim copy and paste, that's the problem right there. The
> semicolon on the end of the while loop tells it to do nothing. It's
> equivalent to:
>
> while ($myrow = mysql_fetch_array($result))
> {
>
> }
>
> So when it goes on, it prints out the table, and $myrow is now an empty
> variable because there were no more rows to fetch. You need to put the
> commands to print out the table heading before the while loop, and the
> printf statement inside the while loop.
>
> Also, unless you know exactly what's coming out of the database, you might
> want to use htmlentities($myrow["columm"])
>
> --
> Michael
>
This is the original snip of script i used. I was getting the same results.
if ($myrow=mysql_fetch_array($result)) {
echo "<table border=1>\n";
echo
"<tr><td>ID</td><td>Username</td><td>Password</td><td>Email</td></tr>\n";
do{
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</tr>\n",$myrow["name"],$myrow["email"],$myrow["phone"],$myrow["company"],$myrow["standard"],$myrow["ecommerce"],$myrow["message"]);
} while($myrow = mysql_fetch_array($result));
echo "</table>\n";
}
--
The sad thing about artificial intelligence is that it lacks artifice and
therefore intelligence.Jean Baudrillard (1929), French semiologist.