Click here to Skip to main content
0 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Can anyone guys help me with this.

Base on the picture below: I have 7 columns and 10 rows.
For each box for example TS Number 1, the only number should be in that box is 0 and so on. It depends on the value that will be pass

Here's the output my code produce
Click this picture



The output should be like this..

Please click this picture


TIA Guys..

What I have tried:

$x=1;
$y=0;
$rows = 10; // define number of rows
$cols = 7;// define number of columns 
for($tr=1;$tr<=$rows;$tr++){

echo '<div class="calendar__week">';
for($td=1;$td<=$cols;$td++){ 
echo '<div class="calendar__day day">TS NUMBER: '. $x;                          
echo '<br><br>';
echo '<c style="color:green; font-size:30px;">';

while($y<$ts_qty){   //$ts_qty will hold the value that has been pass
echo $y;                    

$y++;
}                           
echo '</c></div>';  

$x++;
}               

echo '</div>';

}
Posted
Updated 10-Feb-19 18:20pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Look like the code is using a while loop to print out all the number into a cell but it should only print 1 number per cell.

Maybe an if statement should do it.

Assuming $ts_qty = 5; Then replace the while loop with the following

if ($x<=$ts_qty){   //$ts_qty will hold the value that has been pass
  echo $y;                    
  $y++;
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190419.4 | Last Updated 11 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100