Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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

PHP
if ($x<=$ts_qty){   //$ts_qty will hold the value that has been pass
  echo $y;                    
  $y++;
}
 
Share this answer
 
Comments
Member 14145925 11-Feb-19 0:20am    
wow! thank you so much!! god bless!
Nirav Prabtani 11-Feb-19 1:55am    
Please mark it as a resolved, if it works for you
Nirav Prabtani 11-Feb-19 1:56am    
5+

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900