Having a bit of trouble with some nested PHP inside HTML inside PHP.
Have the following code that works fine on it's own.
echo "<select>";
foreach($all_rooms as $val) {
echo "<option> $val </option>";
}
echo "</select>";
However when i try to place it inside HTML which is nested within the PHP block it doesn't seem to work:
<select id = "room_change'.$booking_id["{$id}"].'" hidden>
'.
foreach($all_rooms as $val) {
"<option>$val </option>";
}
.'
</select>
I have also tried the following code which doesn't seem to work :
<select id = "room_change'.$booking_id["{$id}"].'" hidden>
'. foreach($all_rooms as $val) {
.'<option>'.$val .'</option>'.;
}
.'
</select>
Worth noting that this code is nested inside PHP tags. Full , somewhat irrelevant code :
<?php
echo '<!-- BEGIN content -->
<div id="booking_Requests">
<p>
Name : '.$fname["{$id}"] . ' '.$lname["{$id}"].' </br>
Phone Number : '.$mobile["{$id}"].' </br>
Date : '.$newdate.' </br>
Time : '.$fstart_Time["$id"].' to '.$fend_Time["{$id}"].' </br>
<!-- Displays the requested room -->
Requested room : <label id = "requested_room'.$booking_id["{$id}"].'" visible>'.$room["{$id}"].' </label>
<!-- Hidden Select box that is displayed when user clicks the alter button -->
<select id = "room_change'.$booking_id["{$id}"].'" hidden>
'.
foreach($all_rooms as $val) {
"<option>$val </option>";
}
.'
</select>
<!-- Label that dispays whether or not the room is available -->
<label id = "room_available'.$booking_id["{$id}"].'"> |||| '.$room_blah.'</label>
<!-- Button that allows the user to alter the selected room, calls the function
alterRoomFunc -->
<button type ="button" id = "alter_room'.$booking_id["{$id}"].'"
onclick="alterRoomFunc('.$booking_id["{$id}"].')"> Alter </button>
</br>
Booking ID: '.$booking_id["{$id}"].' </br>
<button type="button" id="'.$booking_id["{$id}"].'"
onclick="accFunc('.$booking_id["{$id}"].')">Accept</button>
<button type="button" id="'.$booking_id["{$id}"].'"
onclick="rejFunc('.$booking_id["{$id}"].')">Reject</button>
</p>
</br>
</div>
'
;
}
?>
$idis a number, so if you use"$id"the program will look for a word named$id, so your program won't find anything