how to populate data from mysql into dropdown using php
this is my code but it only print " $cdTitle " in the list box
$server = 'localhost';
$username = 'root';
$password = '';
$database = 'database';
try{
$conn = new PDO("mysql:host=$server;dbname=$database;", $username, $password);
} catch(PDOException $e){
die( "Connection failed: " . $e->getMessage());
}
$cdquery="SELECT offencetype from offence";
$cdresult=mysql_query($cdquery) or die ("Query to get data from firsttable failed: ".mysql_error());
while ($cdrow=mysql_fetch_array($cdresult)) {
$cdTitle=$cdrow["offencetype"];
echo "";
}
?>
Thanks
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Laxmikanth O185 reputationPosted May 26, 2016, 1:39 PM EDT