Perfect.  Why was I trying to make this more difficult???  Sometimes
the simple solution is definitely the best.

-----Original Message-----
From: Shrock, Court [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 05, 2002 1:50 PM
To: NIPP, SCOTT V (SBCSI); '[EMAIL PROTECTED]'
Subject: RE: [PHP-DB] A real question this time...


You are correct that an assignment between two variable is a copy, and that
is exactly what is happening, however, you need to know what $SA is
originally--it is a resource pointer in ways...it does not hold any data, it
is just an internal pointer to where php is storing the data.  So, when you
do $PASS = $SA, you are simply creating two resource pointers that point to
the same dataset--that is why the internal functions that loop through the
dataset work the first time and not the second.

Instead of trying to loop through twice, why not loop through once, and set
two variables in each iteration of the loop like::

while($name = mysql_fetch_row($SA)) {
   $sa_list .= "<option>$name[0]</option>\n";
   $passed .= "<option>$name[0]</option>\n";
}

> -----Original Message-----
> From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, July 05, 2002 11:44 AM
> To: '[EMAIL PROTECTED]'
> Subject: [PHP-DB] A real question this time...
> 
> 
>       This time I have a real question that I need help with. 
>  I am not sure why something is not working the way I intend 
> it.  This is most likely a mistake in my understanding, but 
> here goes...
>       I have a section of code that populates a dropdown list 
> with the results of a query on a database table.  This works 
> perfectly, and is exactly what I want.  My problem is that I 
> need to use this same data to populate a second dropdown 
> list, and the second list is empty.  I thought that by 
> setting another variable equal to the original prior to it 
> being processed in a loop which populates the first drop down 
> I would be OK, but this doesn't seem to do the trick for me.  
> Here is the section of code that I am working with.  Thanks 
> in advance.
> 
> mysql_select_db($database, $Test);
> $query_SA = "SELECT sbcuid FROM contacts_sa";
> $SA = mysql_query($query_SA, $Test) or die(mysql_error()); 
> $PASS = $SA; $row_SA = mysql_fetch_assoc($SA); $totalRows_SA 
> = mysql_num_rows($SA); $sa_list = "<select size=\"1\" 
> name=\"sa\">\n"; $sa_list .= "<option>SA UID</option>\n"; 
> while($name = mysql_fetch_row($SA)) {
>   $sa_list .= "<option>$name[0]</option>\n";
> }
> $passed = "<select size=\"1\" name=\"pass\">\n";
> $passed .= "<option>SA UID</option>\n";
> $passed .= "<option>------</option>\n";
> while($name = mysql_fetch_row($PASS)) {
>   $passed .= "<option>$name[0]</option>\n";
> }
> 
>       I understand that some of this is unnecessary, but I am 
> using DW MX and do not believe that the extra variable 
> definitions hurt anything.  I might find a use for the row 
> variables down the road anyway.  Correct me if I am wrong 
> though, that these are actual database queries and at least 
> commenting them out could help performance?  That is a 
> secondary question, but thanks agian.
> 
> Scott Nipp
> Phone:  (214) 858-1289
> E-mail:  [EMAIL PROTECTED]
> Web:  http:\\ldsa.sbcld.sbc.com
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to