Drop-down List Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TheFreeman
Forum Newbie
Posts: 3
Joined: Thu Dec 29, 2011 10:57 am

Drop-down List Problem

Post by TheFreeman »

Hey guys I have a problem with populating my drop-down list. Sorry for such questions but I am new to PHP and I have gone through most of the posts and I still cannot solve it.

This is my code below -

Code: Select all

$townDC = new townDC();
$result = $townDC->getTowns();

    echo "<select name=town value=''>Town Name</option>";
        
              while($nt = mysql_fetch_array($result)){
                     
                     echo "<option value=$nt[ID]>$nt[townName]</option>";
              }

echo "</select>";

The result is filled with data just to confirm as I echoed everything to a table.

Thanks in advance
TheFreeman.
TheFreeman
Forum Newbie
Posts: 3
Joined: Thu Dec 29, 2011 10:57 am

Re: Drop-down List Problem

Post by TheFreeman »

It is giving me this problem in the net

Warning: mysql_fetch_assoc() expects parameter 1 to be resource

Hope I get a reply ... I really cant find a solution.

Thanks,
TheFreeman
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Drop-down List Problem

Post by twinedev »

Well in order to help you, we would need to see the code that is actually producing the error, (as the function mysql_fetch-assoc is obviously being called elsewhere by the class/functions you are using in the code you gave). Without the code, we would just be completely guessing.
TheFreeman
Forum Newbie
Posts: 3
Joined: Thu Dec 29, 2011 10:57 am

Re: Drop-down List Problem

Post by TheFreeman »

Hey Guys solved the problem,

Replaced: $nt = mysql_fetch_array($result)
With : $rowc = $resultc->fetch()

Thanks,
TheFreeman
Post Reply