Any idea why this only loops through once? I am trying to have nested panels for each result from the DB. I know there are probably a lot of bad practices here, but I just need it to work for a class. This is never going into production.
while($row = mysql_fetch_array($result)) {
echo sizeof($row);
$resId=$row[reservationId];
$counter++;
try {
$startDate = new DateTime($row[startDate]);
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}
try {
$endDate = new DateTime($row[endDate]);
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}
echo "
<div class=\"panel-group\" id=\"accordion".$counter."\">
<div class=\"panel panel-default\">
<div class=\"panel-heading\">
<h4 class=\"panel-title\"><a class=\"panel-toggle\" data-toggle=\"collapse\" data-parent=\"#accordion".$counter."\" href=\"#collapseInner".$counter."\"><label> ".$row[title]." </label> <label class=\"pull-right\">".$startDate->format('m-d-Y')."</label></a></h4>
</div>
<div id=\"collapseInner".$counter."\" class=\"panel-body collapse\">
<div class=\"panel-inner\">
<div class=\"col-lg-8\">
<p><label>Lodging Reservation #:01-".$row[reservationId]."</label></p>
<p><label>Check In: ".$startDate->format('m-d-Y')."</label></p>
<p><label>Check Out: ".$endDate->format('m-d-Y')."</label></p>
</div>
<div class=\"col-lg-4\">
<button type=\"submit\" class=\"btn btn-primary btn-lg\" data-toggle=\"modal\"
data-target=\"#myModal".$counter."\">
Edit Reservation</button>
<!-- Modal -->
<div class=\"modal fade\" id=\"myModal".$counter."\" tabindex=\"-1\"
role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">
<div class=\"modal-dialog\">
<div class=\"modal-content\">
<div class=\"modal-header\">
<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria
hidden=\"true\">× </button>
<h4 class=\"modal-title\" id=\"myModalLabel\">Edit Reservation</h4>
</div>
<div class=\"modal-body\">
<form method=\"post\" action=\"../controller/EditLodgingReservation.php?
rId=".$resId."&counter=".$counter."\">
<label>Select Dates:</label>
<div class=\"input-group\">
<div class=\"input-group-addon\">
<i class=\"fa fa-calendar\"></i>
</div>
<input type=\"text\" class=\"form-control pull-right\"
id=\"reservation".$counter."\" name=\"reservation".$counter."\">
</div><!-- /.input group -->
<label>Select Lodging</label>
<select multiple=\"\" class=\"form-control\" id=\"lodgingList".$counter."\"
name=\"lodgingList".$counter."\">
";
$result = getlodging();
while($row = mysql_fetch_array($result)) {
echo "<option value=".$row[lodgingId].">".$row[title]." -- $".$row[ratePerDay]."
/night</option>";
}
echo"
</select>
</div>
<div class=\"modal-footer\">
<button type=\"button\" class=\"btn btn-default\" data-
dismiss=\"modal\">Close</button>
<button type=\"submit\" class=\"btn btn-primary\">Save changes</button></a>
</div>
</form>
</div>
</div>
</div>
<p></p>
<form method=\"post\" action=\"../controller/DeleteLodgingReservation.php?
rId=".$resId."&pId=".$personId."\">
<button type=\"submit\" class=\"btn btn-danger btn-lg\">Delete Reservation</button>
</form>
</div>
</div>
</div>
</div>
</div>";
}
?>
while($row = mysql_fetch_array($result)) {twice?$rowkeys would be nice as well ;)