note 94677 rejected from faq.build by danbrown
| From: | danbrown@php.net | Date: | Tue, 17 Nov 2009 22:27:16 +0000 |
| Subject: | note 94677 rejected from faq.build by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163014@lists.php.net to get a copy of this message | ||
Note Submitter: vyjayanth_uttanoor at yahoo dot com
----
Hi, I have this code where I call phy names from User table and display it in a drop down box, now
when I select multiple physicans and save The data gets stored in some format in Refferphysicians
with the Physician Ids. But when I save and reselect that persons details, the previous selected
physicians donot show up. Please help me with a for loop or something so as to see selected when
saved
The insertion procedure for rest is done as stated 'Insertion' below
I have added
$_post['Refer_to_phy'] = serialize ($_post['Refer_to_phy'] );
$_post['Refer_to_phy'] = htmlentities($_post['Refer_to_phy'] );
<select name="Refer_to_phy" multiple="multiple" class='text_9'
style="width:150px" size="6">
<option value=''>--Select
Physicians--</option>
<?php
$vquery_c = "select * from users order by id";
$vsql_c = mysql_query($vquery_c);
while($vrs=mysql_fetch_array($vsql_c))
{
$pro_ty=$vrs["user_type"];
if($pro_ty==1){
$phyName_drop = $vrs['fname'];
if($vrs['fname'] != '' && $vrs['lname'] !=
''){
$phyName_drop = $vrs['lname'].', '.$vrs['fname'];
}
else if($vrs['fname'] == '' && $vrs['lname'] !=
''){
$phyName_drop = $vrs['lname'];
}
$phyName_drop .= $vrs['mname'];
echo "<option value='$vrs[id]' $sel
>".trim(ucwords($phyName_drop))."</option>";
$sel='';
}
}
?>
</select>
Insertion
$insert_id = $objManageData->AddRecords($_POST,'refferPhysician');
function AddRecords($fieldName,$tableName){
$fieldsName = array();
$values = array();
echo 'Skey';
foreach($fieldName as $key => $val){
$fieldname = $val;
$chkStr = substr($key,0,3);
if($chkStr != 'txt') {
$fieldsName[] = $key.'';
$values[] = "'".addslashes($val)."'";
}
}
$fieldsName = implode(",",$fieldsName);
$values = implode(",",$values);
$insertQuery = "Insert into $tableName ($fieldsName) Values ($values)";
$qryId = $this->query($insertQuery);
$inserID = $this->insertID();
return $inserID;
}