traisylee Posted December 3, 2009 Share Posted December 3, 2009 Hi, my problem now is how can i arrange the number be smart?Below is my code number: <html><body><?php$input=3.13;$N=20;for($j=0;$j<=$N;$j++){ $input=$input*3; echo "| " .str_pad($input,15," "). " | " .str_pad($input,15," "). " | " .str_pad($input,15," "). " |</br>";}?></body></html> How can i build my coding be the ouput like below? | 9.39 | 9.39 | 9.39 || 28.17 | 28.17 | 28.17 || 84.51 | 84.51 | 84.51 || 253.53 | 253.53 | 253.53 || 760.59 | 760.59 | 760.59 || 2281.77 | 2281.77 | 2281.77 || 6845.31 | 6845.31 | 6845.31 || 20535.93 | 20535.93 | 20535.93 || 61607.79 | 61607.79 | 61607.79 || 184823.37 | 184823.37 | 184823.37 | I hope got people can help me. Thanks! Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 maybe javascript might be more suitable for this? It might be easier using that and using it to create a loop to print out a table with those numbers in it. Or maybe just cho out HTML table data to organize those numbers, using a loop to make all three columns. Link to comment Share on other sites More sharing options...
Synook Posted December 3, 2009 Share Posted December 3, 2009 What's wrong at the moment? Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 I was thinking it only printed out one column? Link to comment Share on other sites More sharing options...
traisylee Posted December 7, 2009 Author Share Posted December 7, 2009 I was thinking it only printed out one column?My problem is the output can not be arrange like about output.Why u say only can printed out one column?Above coding can printed out 3 column but it can not be arrange better.If i use above coding it will printer out as below: Link to comment Share on other sites More sharing options...
Synook Posted December 7, 2009 Share Posted December 7, 2009 Why not use a <table>? Link to comment Share on other sites More sharing options...
traisylee Posted December 14, 2009 Author Share Posted December 14, 2009 Why not use a <table>?I got try to use table.But can not run it.can i put <table> in the funtion for loop or not? Because when i put it..the programming can't be run. Link to comment Share on other sites More sharing options...
Redroest Posted December 14, 2009 Share Posted December 14, 2009 If you ask me the below code will output the same list in a table format. <html><body><?php$input=3.13;$N=20;echo "<table>";for($j=0;$j<=$N;$j++){ $input=$input*3; echo "<tr><td>|" .str_pad($input,15," "). "|</td><td>|" .str_pad($input,15," "). "|</td><td>|" .str_pad($input,15," "). "|</td></tr>";}echo "</table>";?></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.