redarrow Posted December 30, 2008 Share Posted December 30, 2008 can anybody get the same result with the main array so i don't need to split the array up. this is row 1 this is row 5 this is row 2 this is row 6 this is row 3 this is row 7 this is row 4 this is row 8 current table <table boreder="4"> <?php $array=array("this is row 1","this is row 2","this is row 3","this is row 4", "this is row 5","this is row 6","this is row 7","this is row 8"); $a=array("{$array[0]}","{$array[1]}","{$array[2]}","{$array[3]}"); $b=array("{$array[4]}","{$array[7]}","{$array[6]}","{$array[7]}"); ?> <?php for($i=0; $i<4; $i++){ ?> <tr> <td> <?php echo $a[$i]; ?> </td> <td> <?php echo $b[$i]; ?> </td> </tr> <?php }?> </table> result <table boreder="4"> <tr> <td> this is row 1</td> <td> this is row 5</td> </tr> <tr> <td> this is row 2</td> <td> this is row 8</td> </tr> <tr> <td> this is row 3</td> <td> this is row 7</td> </tr> <tr> <td> this is row 4</td> <td> this is row 8</td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/138902-solved-table-and-array-result-please-help/ Share on other sites More sharing options...
ober Posted December 30, 2008 Share Posted December 30, 2008 <table border="4"> <?php $a = array("this is row 1","this is row 2","this is row 3","this is row 4", "this is row 5","this is row 6","this is row 7","this is row 8"); ?> <?php for($i=0; $i<4; $i++){ ?> <tr> <td> <?php echo $a[$i]; ?> </td> <td> <?php $j = $i + 4; echo $a[$j]; ?> </td> </tr> <?php }?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/138902-solved-table-and-array-result-please-help/#findComment-726345 Share on other sites More sharing options...
redarrow Posted December 30, 2008 Author Share Posted December 30, 2008 Thank you. dont no how you just do it so quickly and perfect so dam good work. Quote Link to comment https://forums.phpfreaks.com/topic/138902-solved-table-and-array-result-please-help/#findComment-726354 Share on other sites More sharing options...
redarrow Posted December 30, 2008 Author Share Posted December 30, 2008 ober thanks mate but, because off the current array needs to be looped 4 times to get the row's correctly looking, The user is restricted to 16 forums only in the admin page at the moment. is there a way to get the number of rows endless. Let say the user had 35 forums added to the database , I want the table to show them rows as meny as he adds to the database. but i want it in the order as you see now. how can i do that will i need to use a switch or is there another way. Quote Link to comment https://forums.phpfreaks.com/topic/138902-solved-table-and-array-result-please-help/#findComment-726358 Share on other sites More sharing options...
redarrow Posted December 30, 2008 Author Share Posted December 30, 2008 Ok ill use a switch, Thanks ober good work nice example cheers. didn't even no that would work thank you. learn some think everyday. Quote Link to comment https://forums.phpfreaks.com/topic/138902-solved-table-and-array-result-please-help/#findComment-726368 Share on other sites More sharing options...
redarrow Posted December 30, 2008 Author Share Posted December 30, 2008 Incase anybody wants to no how to increment the array by 4 thanks to USER: ober. <table align="center" width="1200px"> <?php $a=array("This is froum 1","This is forum 2","This is forum 3","This is forum 4", "This is forum 5","This is forum 6","This is forum 7","This is forum 8", "This is forum 9","This is forum 10","This is forum 11"," This is forum 12", "This is forum 13","This is forum 14","This is frorum 15","This is forum 16"); for($i=0; $i<4; $i++){?> <tr> <td align="center"> <?php echo $a[$i];?> <br><br><br> </td> <td align="center"> <?php $b=$i+4; echo $a[$b];?> <br><br><br> </td> <td align="center"> <?php $c=$b+4; echo $a[$c]; ?> <br><br><br> </td> <td align="center"> <?php $d=$c+4; echo $a[$d]; ?> <br><br><br> </td> </tr> <?php }?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/138902-solved-table-and-array-result-please-help/#findComment-726412 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.