Re: Function fails on second consecutive call
| From: | Rasmus Lerdorf | Date: | Mon, 05 Jun 2000 21:23:25 +0000 |
| Subject: | Re: Function fails on second consecutive call | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1094@lists.php.net to get a copy of this message | ||
Add a reset($tables) call before your while loop
On Mon, 5 Jun 2000, Paul Strange wrote:
> I have a function that pulls data from the database and then displays it on
> the screen (see below for code). If I call this function once, everything
> works fine. However, if I try to call it twice, the first series of data
> shows up but the second does not. Any ideas would be greatly appreciated.
>
> --- <snip> ------
> function showinfo($userid)
> {
> // Global Variables
> global $tables;
>
> $linkid = connection();
>
> echo ("User id = ". $userid);
>
> echo ("<table border ='0'>");
> echo ("<tr>");
>
> while (list($key, $val) = each ($tables["user"]))
> {
> if ($key == 3)
> {
> echo("</tr><tr>");
> }
> $result = my_query("select * from $val where userid='$userid'", $linkid);
> ftable($val, $result);
> }
>
> echo ("</tr>");
> echo ("</table>");
> }
>
> --- <snip> ------
>
> Paul Strange
>
>
>