Jump to content

Recommended Posts

Hello all.

 

I have a registration form. For the line of business I need to select the option from a dropdown which is stored in a (different) table. No rocket-science I would think. But my little script-snippet (see below) only returns a parse-error:

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/deb13456/domains/c-create.net/public_html/fldrx/fldry/register.php on line 54

 

I've been trying to fix this, but unfortunately to no avail so far. Maybe a fresh pair of eyes can point me in the right direction. The main problem is (I think) is that the script is not looking in the correct database table, but where (and how) to put the reference to the table?

 

 

<?php
$arLob = array();
$arLob['lob_a'] = 'lob_a';
$arLob['lob_b'] = 'lob_b';
$arLob['lob_c'] = 'lob_c';
$arLob['lob_d'] = 'lob_d';

// store account id from db here
$lob_id = $row['lob'];

?>
<select name="lob" id="lob">
<?php
foreach($arLob as $key => $lob){
?>
<option value="<?php echo $key?>" <?php echo $lob_id==$key ? 'selected' : null?>><?php echo $Line of business></option>
<?php
}

?>
</select>

Edited by Christiaan

You need to use an editor with syntax highlighting. That would have made the problem clear:

<?php echo $Line of business></option>

<?php

 

At any rate, there's no real reason to jump in and out of php so much for something like this.

 

<?php
$arLob = array();
$arLob['lob_a'] = 'lob_a';
$arLob['lob_b'] = 'lob_b';
$arLob['lob_c'] = 'lob_c';
$arLob['lob_d'] = 'lob_d';

// store account id from db here
$lob_id = $row['lob'];

echo "<select name=\"lob\" id=\"lob\">\n";
foreach($arLob as $key => $lob){
   $selected = $lob_id == $key ? ' selected="selected"' : '';
   echo "<option value=\"$key\"$selected>$lob</option>\n";
}
echo "<select>\n";

Edited by Pikachu2000

Thanks Pikachu.

 

This does display a dropdown, but only with the values entered in the array. (lob_a- lob_d) and NOT the values that are stored in the database table raf_lob.

So this result is the same as an html <select> <option> </option> </select> tag.

In the table I have the actual names of the lob's, which needs to be displayed in the dropdown accordingly.

Edited by Christiaan
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.