I generally set an array if I'm going to reuse a result. In your example, I
would do something like the following:
<? $i=0 ?>
<? while ($speaker = db_fetch_object($qid_speaker)) {
$speakerName[i]=sprintf("%s
%s",$speaker->first_name, $speaker->last_name);
i++;
?>
<option value="<? pv($speaker->first_name)
?> <? pv($speaker->last_name) ?>">
<? pv($speaker->first_name) ?> <?
pv($speaker->last_name) ?>
<? } ?>
</select>
Then the next time I wanted a drop box with the same result set:
<? $j=0;
while ($j<$i)
{
printf("<option value='%s'
>%s",$speakerName[j], $speakerName[j]);
}
?>
I hope this helps...
Pat...
Patrick Sherrill
CocoNet Corporation
SW Florida's 1st ISP
825 SE 47th Terrace
Cape Coral, FL 33904
----- Original Message -----
From: "Scott Swaim" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 21, 2004 11:34 AM
Subject: reuse a results set
I have a form that does the following
<? while ($speaker = db_fetch_object($qid_speaker)) { ?>
<option value="<? pv($speaker->first_name)
?> <? pv($speaker->last_name) ?>">
<? pv($speaker->first_name) ?> <?
pv($speaker->last_name) ?>
<? } ?>
</select>
$qid_speaker = db_query("SELECT first_name, last_name FROM people WHERE
speaker = 'Y' ORDER BY last_name");
I am using this in a form select drop down box.
What I need to do is reuse this results set in another drop down box. but I
can not figure out how to do this.
If I use the mysql_free-result($qid_speaker) and then try to do the query
again I get a mysql_fetch_object(): 12 is not a valid MYSQL result resource.
TIA
Scott Swaim
Quality Corps, Inc.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]