RE: Query to Array to Echo Problem--Thank you

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes!
That worked! (It was returning the same field values not column names, my mistake). Now it returns what it should return. Onwards to the next snafu!
Thanks!
 


"Ryan Jameson (USA)" <RJameson@xxxxxxxxxxx> wrote:
One thing may be that you need to do a fetch to increment the result row
odbc_fetch_row($result);. Though that doesn't explain your column names
being in the array unless that's what's in the table.

<>< Ryan

-----Original Message-----
From: Karen Resplendo [mailto:karenresplendo@xxxxxxxxx] 
Sent: Tuesday, February 24, 2004 5:18 PM
To: php-db@xxxxxxxxxxxxx
Subject:  Query to Array to Echo Problem

Here is the webpage that demonstrates my code problem:
http://170.104.158.16/chemlatestPAGETEST.php3?pwsno=00100

I'm so close I can smell it. Hoping someone can troubleshoot my code.
Here is the piece that doesn't work. It returns the 2 column names, over
and over. For some reason I'm not loading the values from the query.
(Using only 2 columns for now and hardcoding number of rows):

function QueryIntoArray($query){
settype($retval,"array");
/* connect to sdwis server*/
$connectionSDWIS = odbc_connect("xxxx","xxxx","xxxx");
if(!$connectionSDWIS) die("Couldn't connect");
/* select sdwis database */
odbc_do($connectionSDWIS, "use xxxx");

$result= odbc_do($connectionSDWIS,$query); if(!$result){
print "Query Failed"; } for($i=0;$i<100;$i++){
$fields=odbc_num_fields($result);
for($j=1;$j <$fields;$j++){
$retval[$i][odbc_field_name($result,$j)] =
odbc_result($result,$j);
}//end inner loop
}//end outer loop
return $retval;
}//end function


$query = "SELECT DISTINCT PWS, PWSName, CONVERT(varchar(12),
DateCollected, 101), AnalyteName, SourceID, str(Results,7,4), str(MCL,
7,4), UOM, DateCollected FROM ChemMon WHERE PWSID='00100' AND
AnalyteCode NOT IN('3013','3014','3100') ORDER BY DateCollected DESC,
AnalyteName ";

settype($myresult,"array");
$myresult = QueryIntoArray($query);
for($i=0;$i print $myresult[$i]["AnalyteName"];
print $myresult[$i]["UOM"];
}



---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

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


---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux