Hi all,
I'm currently fumbling my way through php, I've become stuck on what I _believe_ is quite a simple matter.
I currently have populated a combobox (location) with values from a table like so:
-->select id="location" name="location"><?php $editprop->Move(0);while ( !$editprop->EOF ) { echo "<option value=\"" . $editprop->fields["suburb"] . "\">" . $editprop->fields["suburb"]. "</option>";$editprop->MoveNext(); } ?></select>
now that that is done, I want to get the value of a specific record from the table and have that as the default selected suburb.
I was hoping this would do the trick:
<option SELECTED value=\"" . $editprop->fields["location"] . "\">" . $editprop->fields["location"]. "</option>
Now, looking at it, I think it would add the value onto the current combobox list, is that correct? I don't actually want that to happen, I just want to get the value and select it (the value would already be in the combobox from the former statement)
So not only do I not know how to do specifically what I want, but this way doesn't work either, I get an error message:
Parse error: parse error, unexpected T_STRING, expecting ']' in /var/www/html/tester.php on line 151
I believe this to be because of simple placement of the two statements. I put the latter statement directly after the first so in all, it looks like this:
--><select id="location" name="location"><?php $editprop->Move(0);while ( !$editprop->EOF ) { echo "<option value=\"" . $editprop->fields["suburb"] . "\">" . $editprop->fields["suburb"]. "</option>";$editprop->MoveNext(); } ?></select><option SELECTED value=\"" . $editprop->fields["location"] . "\">" . $editprop->fields["location"]. "</option>
Note:
I also tried putting the second option statement within the select tags, after the "?>" just before "</select>". This also produced the same error. What am I missing?
So my questions:
How do I get the value and select it from the list?
Where do I place the statement to do that?
If anyone could help that would be great, I have been at this off and on for the past couple of days and all I have managed so far is failure after failure
Any ideas?
Thanks
lordy