[eluser]earlyriser[/eluser]
Dready: thanks for your reply.
I tried your code as you can see below, but I only got a blank page. Any advice?
Code:
function comment_insert()
{
//check if the wine is in database
$this->db->select('*');
$this->db->from('wines');
$this->db->where('name', $_POST['name']);
$data['query']= $this->db->get();
if ($query->num_rows() > 0) //if it was found in wines.name
{
$dbrow = $query->row_array();
$wine_id = $dbrow['id'];
}
else //if it wasnt found in wines.name
{
$this->db->insert('wines',array('name'=>$_POST['name'],'year'=>$_POST['year']));
$wine_id = $this->db->insert_id();
}
//insert comment
$this->db->insert('wine_comments',array('user_id'=>$_POST['user_id'],'wine_id'=>$wine_id,'rating'=>$_POST['rating']));
}