edpatterson
IS-IT--Management
- Feb 24, 2005
- 186
Is there a way to 'rewind' the pointer used by mysql_fetch_field()?
I am trying to step through the results of a query once in 2 different functions.
Inaccurate example put shows the problem
$result = array('serial', 'property', 'mac')
function createTableHeader($result){
$table = "<table border = 1 cellpadding = 3><tr>\n";
while($field = mysql_fetch_field($result)){
$table = $table."<th>$field->name</th>";
}
$table = $table."</tr>\n";
return($table);
}
echo createTableHeader($result);
echo otherFunctionsHere();
echo createTableHeader($result);
The table with header is only printed once, the table is properly closed in one of the otherFunctionsHere();
Ideas?
I am trying to step through the results of a query once in 2 different functions.
Inaccurate example put shows the problem
$result = array('serial', 'property', 'mac')
function createTableHeader($result){
$table = "<table border = 1 cellpadding = 3><tr>\n";
while($field = mysql_fetch_field($result)){
$table = $table."<th>$field->name</th>";
}
$table = $table."</tr>\n";
return($table);
}
echo createTableHeader($result);
echo otherFunctionsHere();
echo createTableHeader($result);
The table with header is only printed once, the table is properly closed in one of the otherFunctionsHere();
Ideas?