Hi, this is the first time I am posting in such a thread so I hope I am doing it the right way. I am trying to populate a drop down menu through php however it is not returning the correct values. Here is the code:

<td>
                    <select name="Towns">
                    <?php                     
                        $result = $dataobject->getTowns();
                        $dsTown = mssql_fetch_array($result);
                        foreach ($dsTown as $TownId => $TownName)
                                   echo("<option value=" . $TownId . ">" . $TownName . "</option>");
                     ?>
                    </select>
                </td>
function getTowns()
	{
		$result = new dbconn();
		$strsql="exec msp_GetTowns";
		$dataset = $result -> connectSql($strsql);
		return $dataset;
	}

Appreciate any help

Member Avatar for diafol

Are you using mysql or mssql?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.