Reputation: 63
I'm having an issue arranging the data returned from a while loop in php.
basically I'm trying to return a time slot schedule of work from a database, problem is i seem to be getting either the same result in all time slots or all clients in one time slot.
What i want:
This 4 times in a row to represent 4 weeks in a month.
Each client name is already editable using jeditable and the grey square using Ajax to tick when the job is done (h=just a visual reminder)
my code
<div class="calendar">
<div class="header">
<div class="ts">TIMESLOT</div>
<div class="day">MON</div>
<div class="day">TUE</div>
<div class="day">WED</div>
<div class="day">THUR</div>
<div class="day">FRI</div>
</div>
<div class="slots">
<div class="time">09:45 - 10:45</div>
<?php
while($ssrow = $scedule->fetch_object()) {
$scid = $ssrow->scid;
$scclient = $ssrow->client;
$sccomplete = $ssrow->completed;
?>
<div class="client"><span id="<?php echo $scid; ?>"><?php echo $scclient; ?></span><div></div></div>
<?php
}
?>
</div>
</div>
This throws all the client names out in one huge mess and makes my head hurt trying to fix it... any help is highly appreciated here...
My Call to PHP Function
$scedule = seoschedule();
seo schedule function
function seoschedule() {
$mysqli = DB::connection();
return $mysqli->query('SELECT * FROM seoschedule');
}
Upvotes: 0
Views: 168
Reputation: 10469
From your bit of code it looks like everything will be output into the one div:
<div class="time">09:45 - 10:45</div>
<?php
while($ssrow = $scedule->fetch_object()) {
--> output data
}
?>
</div>
You never increment the 'time' in your loop.
It would appear that you need an outer loop to create the 'time' div and then an inner loop with the corresponding values for that time.
Upvotes: 1