0

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');

}

2
  • what's your query for actually getting the schedule? I wonder if that would help us find you a solution. Also, I'm thinking if some of the cells should appear as empty because no client has signed up for that slot yet, then maybe you need to unset the client variables, otherwise, the empty cell will display the variables from the previous row in the database. Commented Jan 26, 2012 at 13:17
  • ive added the call to the function & the function itself Commented Jan 26, 2012 at 13:22

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.