I'm having issues databinding a dropdown list. I'm following a MVC structure and this is how I did it.
Here is a function from my Model layer:
function GetTillverkare()
{
$data = array();
mysql_set_charset('utf8');
$query = "Select Namn from Tillverkare";
if(!$sql = mysql_query($query)) {
throw new exception("Error: Can not execute the query.");
} else {
$num = mysql_num_rows($sql);
if($num>0)
{
for($i=0; $i<$num; $i++)
{
$data[$i] = mysql_fetch_array($sql);
}
}
}
return $data;
}
Here is the code from my Controller layer:
$displayResults = new Sok() //Sok is my model class.
$GetTillverkare = $displayResults->getTillverkare();
//I am able to print the $GetTillverkare so there is no problem with getting the data.
Here is my View layer
Fabrikat:<br /> <select name="Tillverkare_search" id="Tillverkare_search">
<option value="" selected="selected">Pick</option>
<option value="<?php echo $GetTillverkare ?>"</option>
</select><br/>
I don't get any error, but it doesn't display data o the dropdown list. It's empty