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 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Laxmikanth OPosted May 26, 2016, 5:39 PM