M0n5terBunny Posted October 15, 2011 Share Posted October 15, 2011 hello all i was wondering how to valign this php code because it won't work i have tried echo a table putting everything in a table and that didn't work, only thing that does work is doing the whole <pre> </pre> and thats somewhat irritating any ideas ? <html><head> <title>Numbers</title> </head> <body> <center><font face=arial> <?php $v1 = "Vouchers "; $v2 = "Free Support "; $v3 = "a Hug "; $v4 = "LOSER "; $n2 = rand(0,100); $n3 = rand(0,100); $n4 = rand(0,100); $n5 = rand(0,100); $n6 = rand(0,100); $n7 = rand(0,100); $n8 = rand(0,100); $n9 = rand(0,100); $n10 = rand(0,100); $number = ($n2+$n3+$n4+$n5+$n6+$n7+$n8+$n9+$n10); if ( $number > 1 && $number < 20 ) { echo $v1; } if ( $number > 21 && $number < 40 ) { echo $v2; } if ( $number > 41 && $number < 60 ) { echo $v3; } if ( $number > 61 && $number < 999 ) { echo $v4; } echo $number; ?> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/249183-valign-php-code/ Share on other sites More sharing options...
teynon Posted October 15, 2011 Share Posted October 15, 2011 I'm not exactly sure what you are trying to do, but maybe this is what you are trying to do: <html><head> <title>Numbers</title> </head> <body> <center><font face=arial> <?php $v1 = "Vouchers "; $v2 = "Free Support "; $v3 = "a Hug "; $v4 = "LOSER "; $n2 = rand(0,100); $n3 = rand(0,100); $n4 = rand(0,100); $n5 = rand(0,100); $n6 = rand(0,100); $n7 = rand(0,100); $n8 = rand(0,100); $n9 = rand(0,100); $n10 = rand(0,100); $number = ($n2+$n3+$n4+$n5+$n6+$n7+$n8+$n9+$n10); if ( $number > 1 && $number < 20 ) { echo $v1; } if ( $number > 21 && $number < 40 ) { echo $v2; } if ( $number > 41 && $number < 60 ) { echo $v3; } if ( $number > 61 && $number < 999 ) { echo $v4; } echo "<br />".$number; ?> </font></center> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/249183-valign-php-code/#findComment-1279621 Share on other sites More sharing options...
MasterACE14 Posted October 16, 2011 Share Posted October 16, 2011 <html><head> <title>Numbers</title> </head> <body> <div style="margin: 0 auto; text-align: center;"> <?php $v1 = "Vouchers "; $v2 = "Free Support "; $v3 = "a Hug "; $v4 = "LOSER "; $n2 = rand(0,100); $n3 = rand(0,100); $n4 = rand(0,100); $n5 = rand(0,100); $n6 = rand(0,100); $n7 = rand(0,100); $n8 = rand(0,100); $n9 = rand(0,100); $n10 = rand(0,100); $number = ($n2+$n3+$n4+$n5+$n6+$n7+$n8+$n9+$n10); if ( $number > 1 && $number < 20 ) { echo $v1; } if ( $number > 21 && $number < 40 ) { echo $v2; } if ( $number > 41 && $number < 60 ) { echo $v3; } if ( $number > 61 && $number < 999 ) { echo $v4; } echo $number; ?> </div> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/249183-valign-php-code/#findComment-1279670 Share on other sites More sharing options...
teynon Posted October 16, 2011 Share Posted October 16, 2011 Ok, the <center> tag should actually work, but it has been deprecated so you should use MasterACE14's idea with the DIV. However, it will not make your text appear vertical aligned, just centered. You could also generate the code a little better: <html><head> <title>Numbers</title> </head> <body> <div style="margin: 0 auto; text-align: center;"> <?php $output = array("Vouchers ", "Free Support ", "a Hug ", "LOSER "); $number = rand(0,1000); if ($number < 20) { echo $output[0]; } else if ($number < 40) { echo $output[1]; } else if ($number < 60) { echo $output[2]; } else if ($number >= 60) { echo $output[3]; } echo "<br>{$number}"; ?> </div> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/249183-valign-php-code/#findComment-1279679 Share on other sites More sharing options...
M0n5terBunny Posted October 27, 2011 Author Share Posted October 27, 2011 thank you worked perfectly Quote Link to comment https://forums.phpfreaks.com/topic/249183-valign-php-code/#findComment-1282612 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.