I was wondering if it is possible to use the same query result twice as I am having problems with this.
Lets say I run this query:
$sql = "SELECT user_name,ID FROM users
WHERE show_admin = 1 ORDER BY user_name ";
$solicitor = mysql_query($sql);
Then lets say I run this function inside a form to populate a dropdown box.
function showClients($solicitor) {
while ($row = mysql_fetch_array($solicitor, MYSQL_ASSOC)) {
print "<option value= '$row[ID]'>$row[location]<br>\n";
}
}
If I then try and use the $solicitor result set again in another function
function legalstream($solicitor) {
$client_index = 0 ;
while ($row = mysql_fetch_array($solicitor, MYSQL_ASSOC)) {
if ($row[user_name] == "LEGALSTREAM") {
$legalstream = $client_index + 1 ;
return $legalstream ;
}
$client_index = $client_index + 1 ;
}
}
I get the mysql_fetch_array(): supplied argument is not a valid MySQL result resource error.
Everything works fine if I run the query twice and use different result names for each function
Thanks
Jm Durand