stopping an array from clearing data after function call
Posted: Fri Apr 24, 2009 3:28 pm
i'm getting data from a table and I'm running it through a function to extract all the rows from each field. Here is the function:
I'm calling this function from here:
I think when i make the first call it is erasing the contents of the array from my $show_all SELECT statement. I have to uncomment the second $show_all in order for the function mysql_fetch_all to return the #2 data.
I don't want to have to make another query to call the function again (unless there isn't another way). Thanks in advance...
Code: Select all
function mysql_fetch_all($result, $number) {
while($row=mysql_fetch_array($result)) {
echo $row[$number]."<br>";
$return[] = $row;
}
return $return;
}
Code: Select all
function showTable($table_name, $primary_key, $index, $secondary_column, $div_header, $div_header2, $divID, $divID2){
$show_all = mysql_query("SELECT * FROM $table_name WHERE $primary_key < 100");
echo "<div id='$divID'><h4>".$div_header."</h4><p>";
mysql_fetch_all($show_all, 1);
echo "</p></div>";
echo "<div id='$divID2'><h4>". $div_header2."</h4><p>";
// $show_all = mysql_query("SELECT * FROM $table_name WHERE $primary_key < 100");
mysql_fetch_all($show_all, 2);
echo "</p></div>";
}
I don't want to have to make another query to call the function again (unless there isn't another way). Thanks in advance...