Re: While + Function

From: Date: Thu, 23 Jan 2003 09:54:19 +0000
Subject: Re: While + Function
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-25061@lists.php.net to get a copy of this message
On Thursday 23 January 2003 06:04, Shahar Tal wrote: > Hello all! > > I got one page, with this code: > > <?php > echo insert_results(); > ?> > > Which grabs the data I send from another page, on that function. > Here is the important part of the function while code: > > while ($row = mysql_fetch_array($result)){ > function insert_results () { > extract($row); > echo "bla"; > } > } > > Ok, this is the problem. > As you can see, it takes the data from the dattabase, sticks it into the > function, and then the second page displays it. > don't get me wrong, this is working PERFECTLY and just the way I want it, > and then comes my problem. > It works only with one row. it displays only one row, even when I know > there are more. no matter how many rows are in the database, > it will always output one "bla". > > I need to move on and display all the rows, just like 'while' should work, > I don't know why it's not working. > Maybe I should stick it into a function array? but that's a bit strange as > the 'while' command should do it automaticlly. Why have you defined your function insert_results() inside your while-loop? You be doing something like this instead: function insert_results($row) { do_insert_row; } while ($row = mysql_fetch_array($result)) { insert_results($row); } -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Joe's sister puts spaghetti in her shoes! */

« previous php.db (#25061) next »