I’m trying to generate a value, not on database-side like auto key stuff, but on the front end or on the client side.. Do you have any clever idea to do that? Because Booking ref is not my primary key, it can’t be autogenerated. What I want to do is to have an initial value of 10307 then increment it, whenever user/s create/s new record.
But what I’ve tried so far is this in PHP:
private function inputBookingRef() {
$value = $this->bookingRef;
$html = "";
$value = 10307;
$value++;
$html .= '<label for="ref">Booking Ref: </label>';
$html .= HTML::inputText("ref", 20, $value) . PHP_EOL;
return $html;
}
NOTE:
My initial value is 10307, then I use the increment operator to make it 10308. But every time I create another record it just gives 10308. I think there must be some clever way to make it increment.
Any help is welcome. Thanks.
Since you are saving the value in db, you just have to fetch the value from database and pass that value to your function, so everytime it will be incrementing your previous value.
And fnally Insert the new $value into the Db