Jump to content

Valign PHP code


M0n5terBunny

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/249183-valign-php-code/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/249183-valign-php-code/#findComment-1279621
Share on other sites

<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>

Link to comment
https://forums.phpfreaks.com/topic/249183-valign-php-code/#findComment-1279670
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/249183-valign-php-code/#findComment-1279679
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.