Page 1 of 1

Drop-down List Problem

Posted: Thu Dec 29, 2011 11:00 am
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.

Re: Drop-down List Problem

Posted: Thu Dec 29, 2011 11:46 am
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

Re: Drop-down List Problem

Posted: Thu Dec 29, 2011 11:06 pm
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.

Re: Drop-down List Problem

Posted: Fri Dec 30, 2011 5:48 am
by TheFreeman
Hey Guys solved the problem,

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

Thanks,
TheFreeman