[eluser]andieevans[/eluser]
Hi
I have some code which check for a number of records in a database before allowing the form data to be added...
now I have a check box which once ticked on the form and the user submits, the form data needs to be added to a table, but only if there are less than x records...
using the code below, how do i get the userid into the function?
Code:
if ($this->input->post('mycheckbox'))
{
$this->form_validation->set_rules('mycheckbox','My Checkbox','callback_count_records');
}
Code:
public function count_records($uid=0)
{
$q = $this->db->query("SELECT * FROM mytable WHERE userid = ".$uid );
$c = $q->num_rows();
if ($c > 19)
return false;
else
return true;
}