I have a database made available to me in .mdb form, and am trying to create a droplist of unique values from the 'Server' column of the 'EventCombMT' table.
Infortunately, while print_r() reveals that I am picking up the values, I can't seem to build the list.
I think my code, cobbled together with outside help, is good up to the $nArraySize = count($mydata); line which I put in as a debug line, but that returns zero.
Can anyone tell me where I've gone wrong? I'm pretty new to PHP, and I;m stumped.
Regards,
Rob
PHP Code:
<form ACTION="$PHP_SELF" METHOD=POST style="margin: 0; align:left;"> <SELECT NAME="report" onChange="jumpTo(this);"> <option VALUE="">-= Choose A Server =- <?php // read distinct values from servers field of EventCombMT table into array $mydata = array(); # initialize our data array $query = "SELECT DISTINCT Server FROM EventCombMT ORDER BY Server;"; $result = odbc_exec($connectionstring, $query); while(odbc_fetch_into($result, $row)) { # $row is an array of the values in the current row of the result set $mydata[] = $row[0]; } // build droplist form element by looping through the array $nArraySize = count($mydata); echo "array size is $nArraySize"; for($index=0; $index < $nArraySize; $index++) { print " <option value='?server=".$row[$index]."'>".row[$index]."\n"; // max. index is always number of entries - 1 because index starts at zero } ?> </SELECT> </form>
|