Jump to content

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...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.