PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
What you could do is get php to choose a random number between 1 and 4 and save it as a variable, then have your 4 different outputs set for each random number.
You can do a different for loop for each row. Example: for($number = 1; $number <= max_rows; $number + X), and you'd get X by finding out how many rows/columns you have. In your example, X would be 3. Then you can run through that loop with different presets for $number to populate the rest of the rows.
limitdesigns wrote:You can do a different for loop for each row. Example: for($number = 1; $number <= max_rows; $number + X), and you'd get X by finding out how many rows/columns you have. In your example, X would be 3. Then you can run through that loop with different presets for $number to populate the rest of the rows.
but my problem is how to put numbers inside?
this the output I'm trying to get :
Ouput1:
1 2 3 4
5 6 7 8
9 10 11 12
Well, you did it for example 1 and 3, right? So before each for loop, type <tr>, then within the for loop have <td><?php echo $number;?></td>, and at the end of the for loop close your row with </tr>. Then repeat for however many rows you want.
limitdesigns wrote:Well, you did it for example 1 and 3, right? So before each for loop, type <tr>, then within the for loop have <td><?php echo $number;?></td>, and at the end of the for loop close your row with </tr>. Then repeat for however many rows you want.
Thanks @ limitdesigns
I'm going to try that, I will update it if I have something
You need multiple for loops, one for each row. And instead of writing $i++, you would need to write $i + 3 (in this case), because the numbers in each row of your table increase by 3 from left to right. Assuming you have three rows, you would write: