Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Trying to build a droplist of uniqe values
Old 12-21-2005, 08:44 AM Trying to build a droplist of uniqe values
Junior Talker

Posts: 2
Trades: 0
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>
scaiferw is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-21-2005, 09:20 AM potential fix
Novice Talker

Posts: 12
Trades: 0
try using a foreach to break apart $row into single entities and use the array_push function instead of setting both arrays equal to each other.
synapsex is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Trying to build a droplist of uniqe values
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09590 seconds with 12 queries