Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: issues two different insert query in one form in codeginter

abbas shah:

I tried to one form Insert to different one table name is horses and other is table name is filename_img query means i have different fields in one table and other i want to insert image to other table but my one form to insert fields and images this is my model and please confirm my query what i am going wrong because show the query show for query error thanks advances


**model**
function horses_insert($data){
$postcode = addslashes($data['postcode']);
$height = addslashes($data['height']);
$breed_id = addslashes($data['breed_id']);
$colour_id = addslashes($data['colour_id']);
$age = addslashes($data['age']);
$gender = addslashes($data['gender']);
$name = addslashes($data['name']);
$price = addslashes($data['price']);
$description = addslashes($data['description']);
// $image = addslashes($data['image']);
$status = addslashes($data['status']);
$price_currency = addslashes($data['price_currency']);
$height_unit = addslashes($data['height_unit']);
$is_urgent = addslashes($data['is_urgent']);
$is_featured = addslashes($data['is_featured']);
$is_spotlight = addslashes($data['is_spotlight']);
$is_sale = addslashes($data['is_sale']);
if($is_urgent=="on"){
$is_urgent="1";
}else{
$is_urgent="0";
}

if($is_featured=="on"){
$is_featured="1";
}else{
$is_featured="0";
}

if($is_spotlight=="on"){
$is_spotlight="1";
}else{
$is_spotlight="0";
}

if($is_sale=="on"){
$is_sale="1";
}else{
$is_sale="0";
}




$result= $this->db->query("INSERT INTO horses (postcode,height,breed_id,colour_id,age,gender,name,price, description,is_urgent,is_featured,is_spotlight,is_sale,status,price_currency,height_unit) VALUES ('$postcode','$height','$breed_id','$colour_id','$age','$gender','$name','$price','$description','$is_urgent','$is_featured','$is_spotlight','$is_sale','$status','$price_currency','$height_unit')");
$id=$this->db->insert_id();

//return $id;
if ($result) {
$userfile = addslashes($data['userfile']);

$query= $this->db->query("INSERT INTO filename_img (userfile,$id) VALUES ('$userfile','')");
$id=$this->db->insert_id();
return $id;
}

}



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: issues two different insert query in one form in codeginter

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×