consider the following code:

$result=mysql_query($sql);
$datas=mysql_fetch_array($result);
$row=mysql_fetch_row($datas);
$num_rows=mysql_num_rows($result);
 for ($counter=0;$counter<$num_rows;$counter++) {

            echo("<option value={$datas[$counter]['name']}>{$datas['name']}</option>");
}

the problem is that it only picks the first record in the mysql database and duplicates it. can somebody help me solve this error

you can do it in while loop

while ($row = mysql_fetch_array($result)){
    echo "<option value = '".$row['name']."'>".$row['name']."</option>";
}
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.