I notice that you are concatinating then each time. try setting them to =""
before using them
$companyID_string = "";
$companyName_string = "";
then:
while()
{
$companyID_string .= "," . $query_data[0];
$companyName_string .= "," . $query_data[1];
}
Jim
ps. try using the mysql_fetch_array() and calling to the vars as
$query_data[<col_name>] instead.
----- Original Message -----
From: "Kurt Lieber" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 25, 2001 12:51 PM
Subject: [PHP] while() looping over query results twice?
> I'm executing a query that returns some a UID and a company name. I'm
using
> the following code to loop over that query result set:
>
> $result = mysql_query($myQuery) //$myQuery gets defined earlier
> $resultCount = mysql_num_rows($result);
> $companyID = array();
> while($query_data = mysql_fetch_row($result)) {
> $companyID[$query_data[0]] = $query_data[1];
> $companyID_string .= "," . $query_data[0];
> $companyName_string .= "," . $query_data[1];
> }
>
> I've used $resultCount to verify the query is returning 4 rows. However,
the
> while loop above is looping over the results twice -- $companyID_string
and
> $companyName_string each have 8 values. Looking at the values shows that
> it's the 4 rows duplicated.
>
> What the heck am I doing wrong?
>
> --kurt
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]