[eluser]kre8ivdesigns[/eluser]
I am new to MySql and trying to build a database for a beach house for my cousin. She is renting it out and needs an availability script. What I have done so far is built a form that asks for basic client information that is stored in client table. The dates they choose is stored in avail table. What I need help with is how to link the dates to the client so I can recall the dates later for that client. If there is a simpler way to do this please let me know.
Table avail = id, dates, client
Table client = id, firstname, lastname, email, phone, begindate, numberdays
Code:
//input new client
$u = new Client();
$u->firstname = $this->input->post('firstname');
$u->lastname = $this->input->post('lastname');
$u->email = $this->input->post('email');
$u->phone = $this->input->post('phone');
$u->begindate = $this->input->post('begindate');
$u->numberdays = $this->input->post('numberdays');
$u->save();
//input dates to book
$date = $this->input->post('begindate');
$days = $this->input->post('numberdays');
$i = 1;
while ($i<$days) {
$newdates = strtotime('+'.$i.' day', strtotime($date));
$booking[$i] = date('Y-m-d', $newdates);
$individualdate = $booking[$i];
//update individual
$u = new Avail();
$u->bookdate = $individualdate;
$u->save();
++$i;
}