0

I have a program like the one below, how do I make the selected reservation id not reappear when adding data?

<div class="form-group">
    <label for="reservation_id" class="col-md-4 control-label">Reservation</label>
    <div class="col-md-8">
        <select name="reservation_id" class="form-control">
            <option value="">select reservation</option>
            <?php 
            foreach($all_reservations as $reservation)
            {
                $selected = ($reservation['id'] == $this->input->post('reservation_id')) ? ' selected="selected"' : "";

                echo '<option value="'.$reservation['id'].'" '.$selected.'>'.$reservation['id'].'</option>';
            }
            ?>
        </select>
    </div>
</div>
  • 1
    Hi, could you explain a bit more? – Hasta Dhana Jan 18 '19 at 15:51
  • I have a program like travel.com, in the program I have relations in the database between the reservation table and the payment table. I want so that in my program I do not bring up the reservation ID that has been added before. – Mohamad Agung Faisal Jan 18 '19 at 16:38
  • Well if that's the requirements, then you could get the available reservation id by using subquery to get the selected reservation id, and the main query to get the available reservation id, something like : `"SELECT * FROM reservation_table WHERE reservation_id NOT IN ( SELECT reservation_id FROM payment_table )"` – Hasta Dhana Jan 18 '19 at 17:53
  • simple way is to use `Get` for that. Its good for Search results and pagination for example. – Ali Qorbani Jan 19 '19 at 06:05

0 Answers0