@mthomas I know you guys are wizards, as this forum has helped me a lot in my small programming career.
Here is the code :
function addProductsData($data){
if($data['id']!=''){
$sql = "Select * from `product_details` where id = " . $data['id'];
$tempData = $this->CommonClass1->ResultWithArrayData($sql);
// echo "<pre>"; var_dump($tempData);exit;
if(isset($_FILES['image']['name']) && !empty($_FILES['image']['name']) && $_FILES['image']['name']!=''){
$countfiles = count($_FILES['image']['name']);
$temp = '';
for($i=0;$i<$countfiles;$i++){
$uploadpic=date('Y_m_d_h_i_s').'_'.str_replace(' ', '',$_FILES['image']['name'][$i]);
move_uploaded_file($_FILES['image']['tmp_name'][$i],'uploads/products/'.$uploadpic);
$temp = $temp . $uploadpic . '#';
}
$tempImageName = $tempData[0]['image'] . $temp;
$sql = "UPDATE `product_details` SET `heading`='".$data['heading']."',`message`='".$data['message']."',`description`='".$data['description']."',`additional`='".$data['additional']."',`image`='".$tempImageName."' WHERE id=".$data['id']."";
$status = $this->CommonClass1->NormalQuery($sql);
return $status;
}else{
;
}
}
else{
if(isset($_FILES['image']['name']) && !empty($_FILES['image']['name'])){
$countfiles = count($_FILES['image']['name']);
$temp = '';
for($i=0;$i<$countfiles;$i++){
$uploadpic=date('Y_m_d_h_i_s').'_'.str_replace(' ', '',$_FILES['image']['name'][$i]);
move_uploaded_file($_FILES['image']['tmp_name'][$i],'uploads/products/'.$uploadpic);
$temp = $temp . $uploadpic . '#';
}
$data['image']=$temp;
}
return $this->CommonClass1->NormalQuery("INSERT INTO `product_details`(`heading`,`message`,`image`,`description`,`additional`) VALUES ('".$data['heading']."','".$data['message']."','".$data['image']."','".$data['description']."','".$data['additional']."') ");
}
}