Thank you for your help and suggestions.
Quote:demyr So, Why don't you just use :<option value="pending" <?php if($booking->status == "pending"){echo 'selected';} ?>>Pending</option>
That's what I did in the end. Created a little helper:
PHP Code:
function isSelected($selectName, $value) {
if(isset($value)) {
if($selectName == $value) return 'selected';
}
return false;
}
And I can use it on all my selects. I just don't like to do ifs and echos inside the html, i find the readability messy.
PHP Code:
<option value="confirmed" <?= isSelected('confirmed', $booking->status) ;?>>Confirmed</option>
I thought the set_select function would do that for me, but I understood it wrong.
Quote:By the way, keep your status as tiny_int in your database instead of varchar.
0 = pending
1 = option
2 = confirmed
etc
I am using varchar for the status because I find them also more readable, but I am always happy to improve my code and learn. Can you explain your recommendation? Is it for performance? to prevent the database to become too heavy? I won't have more than maybe a hundred of records per year in the bookings table.
Quote:Additionally, in your method be careful with double semicolon
Code:
->first();; and try to place "where" after "join"s.
Thanks for spotting that, I corrected it.