I've been trying various ideas for getting something like this to work. Most of them end up in a infinite loop...
Imagine the following;
<?php
while ($row = mssql_fetch_row(mssql_query("$query"))) {
print_r($row);
}
?>
Just like mssql_fetch_row returns a array for each row found. How can I accomplish the same thing in my do_something function.
IE; do_something would take some parameters given to it and end up returning say 5 arrays, just like mssql_fetch_row would return 5 outputs of $row when it find 5 records.
<?php
function do_something($this,$that) {
//outputs a number of things
}
while ($temp = do_something($this,$that)) {
echo "$temp"; //output each number of those things separately as the $temp variable to manipulate no set way
}
?>
I realize this could be done using a foreach instead of a while loop, where the function creates a nested array and your foreach uses that function and goes through each array, etc. Im curious to know how the mssql_fetch_row(result) does this.
Question
Klownicle
I've been trying various ideas for getting something like this to work. Most of them end up in a infinite loop...
Imagine the following;
<?php while ($row = mssql_fetch_row(mssql_query("$query"))) { print_r($row); } ?>Just like mssql_fetch_row returns a array for each row found. How can I accomplish the same thing in my do_something function.
IE; do_something would take some parameters given to it and end up returning say 5 arrays, just like mssql_fetch_row would return 5 outputs of $row when it find 5 records.
<?php function do_something($this,$that) { //outputs a number of things } while ($temp = do_something($this,$that)) { echo "$temp"; //output each number of those things separately as the $temp variable to manipulate no set way } ?>I realize this could be done using a foreach instead of a while loop, where the function creates a nested array and your foreach uses that function and goes through each array, etc. Im curious to know how the mssql_fetch_row(result) does this.
:-/
Link to comment
Share on other sites
5 answers to this question
Recommended Posts