I have a PHP registration that calls a mysql db for a dropdown box. No worries, it works fine. What I can't figure out though is this:
The box HAS TO populate with a name, but the POST needs to go to an id field. What I mean is this:
REGISTRATION.PHP
function generate_business_selections($default = '')
{
$output = '';
$application =& application();
$sql =& sql();
$lang_col = $application->get_language(LANG_COLUMN);
$query = "SELECT id, name_en, {$lang_col} FROM ".DB_DEFAULT_PREFIX."members WHERE profile_type='Business'";
$results = $sql->query($query);
$num_rows = $sql->num_rows(); $sql_counter = 0;
while($num_rows>$sql_counter++)
{
$this_result = $sql->fetch(MYSQL_ASSOC,$results);
$output .= "\t" . '<option value="'.$this_result["name_en"].'"'.($default==$this_result["name_en"] ? ' selected' : '').'>'.$this_result[$lang_col].'</option>' . "\n";
}
return $output;
}
REGISTRATIONCOMPLETE.PHP
$member_array["linkedid"] = $application->clean_input('register_business_selection','trim');
This achieves pulling the name into the box, but what I need to know is how to return just the id to another field in the db. That field is comma delimitted numbers (I didn't design the db, so don't blame me for that one!). It needs to populate the field with the id of the named object. For sake of argument:
id = 2
name_en = Bob Jones
field to insert to = linkedid And this must be populated with the ID, not the name_en.
Gosh, that is so discombobulated. Hope it makes sense to someone! :)
Thanks!