I'm having a problem when I try to use an optionbox whithin a class function.
I'm using the code below:
- Code: Select all
class golfbaan
{
public $golfbaan = NULL;
public $aantal_lussen = NULL;
public $banen;
private $retrieve_banen_sql = "SELECT baan FROM baan_055 ORDER BY baan";
private $result_retrieve_banen;
private $verbinding;
private $data_baan;
public $baan;
public $optiontekst = "-- Selecteer --";
public $result_baan;
function RetrieveBanen()
{
$this->verbinding = new verbinding;
$this->verbinding->verbinden();
$this->verbinding->selecteren();
$this->result_retrieve_banen=mysql_query($this->retrieve_banen_sql)or die("Query om banen op te halen geeft fout: ".mysql_error());
return $this->result_retrieve_banen;
}
function ShowOptionbox()
{
echo "<form name=\"golfronde\" method=\"post\" style=\"color:#00F\">";
echo "<fieldset style=\"border-color: #0CF; color:#00F\">";
echo "<legend style=\"color:#F90\">Invoeren S.V.P.</legend>";
echo "<table width=\"700\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">";
echo "<tr>";
echo "<th scope=\"col\" align=\"left\" style=\"font:Verdana, Geneva, sans-serif; font-size:14px\" width=\"220\"></th>";
echo "<th scope=\"col\" align=\"center\" style=\"font:Verdana, Geneva, sans-serif; font-size:14px\" width=\"20\"></th>";
echo "<th scope=\"col\" align=\"left\" style=\"font:Verdana, Geneva, sans-serif; font-size:14px\" width=\"180\"></th>";
echo "<th scope=\"col\" align=\"left\" style=\"font:Verdana, Geneva, sans-serif; font-size:14px; color:#F00\" width=\"240\"></th>";
echo "</tr><tr><td>Golfbaan</td><td> : </td><td>";
echo "<select name=\"baan\" style=\"background-color:#D5FFFF; font-size:14px; color:#00F; font:Verdana, Geneva, sans-serif\" onchange=\"verwerk()\">";
echo "<option value=\"" . $this->optiontekst . "\"";
$this->baan = $baan;
if ($this->baan == NULL)
{
echo "selected=\"selected\"";
}
echo ">-- Selecteer --</option>";
$this->result_baan = $this->RetrieveBanen();
while ($this->data_baan=mysql_fetch_array($this->result_baan))
{
echo "<option value=\"$this->data_baan[baan]\" ";
if($this->baan == $this->data_baan['baan'])
{
echo "selected=\"selected\"";
}
echo (">$this->data_baan[baan]</option>");
}
}
}
The line echo "<option value=\"$this->data_baan[baan]\" ";" is cousing a problem because the variable "$this->data_baan[baan]" isn't interpreted as a variable.
The optionbox gives the right number of selected records, but the content in the optionbox is "Array[baan]" instead of the attribute value.
Am I using OO wrong or can sombody give me a hint?
Thank you in advance
cees fortuin