I am having a problem with getting the value of an auto incremented column=reservation_no on table reserves

Submitted by: 
Visitors have accessed this post 1996 times.

function add_new_reservation($reservation_no,$user_id,$date_from,$date_to,$location,$comments,$items = array()) {
$user_id=$this->session->userdata('user_id');
$data=array(
'user_id'=> $user_id,
'date_from'=>$date_from,
'date_to'=> $date_to,
'location'=> $location,
'comments'=>$comments
);
$this->db->insert('reserves',$data);

$query = "SELECT max(reservation_no) as mx from reserves where user_id =2";

$query = $this->db->query($query);

foreach ($query->result() as $row){
$res_no = $row->mx;
for($x = 0; $x $sql = "INSERT INTO reserved_items values($res_no,$items[$x],1)";
$this->db->query($sql);

}
}
}

==i have tried using max function to get the last reservation number..
i have reserves table and reserved_items table..i have to get the reservation_no value of reserves to insert it on reservation_no of reserved_items..

kindly, help me out with this one?:(


Tags: 

Comments

Hi, What was the error thrown?

p'nam

..when i try this script for uploading images for local ok naman
pero pag sa domain na may error na..

if ($error > 0)
{
die("Error uploading file! Code $error.");}
else
{
if($size > 1028)
{
die("Format is not allowed or file size is too big!");
}
else
{
move_uploaded_file($temp,"Upload/".$name);
}
header("Location:index.php");
exit;
}
}

[email protected]
09295218029

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.