Positionng with CSS and PHP
This tute assumes you have knowledge of absolute positioning with CSS already. If you have access to PHP on your server you can easily use it with HTML and CSS to position many tables of the same code without having to put the code on the page more than once. Here is a sample page.
The rules are these:
- Your HTML code must not have any quotes inside it or hash marks.
- The HTML code must be placed between <?php and ?>
- You must name your HTML code with a php variable and put the whole block of code between quotes and end with a semicolon like this:
$name = "HTML code goes here";
- None of the above codes will show anything on your page. You have to call the PHP code by the echo command followed by a semicolon ike this.
echo $name;
All of the code goes in your first CSS div tag. If nothing still shows after calling the code check for punctuation, etc. PHP does not allow for error.
- To call the code again on the same page between your CSS div tags just put the div tags, the php tags and the variable name, like this:
<div id="A">
<?php
echo $name;
?>
</div>
you can also write the php code on one line like this:
<div id="A"> <?php echo $name; ?> </div>
See it all on this page:
Further you can add PHP loops to your code between the div tags so that it will print out the code more than once in a div tag. Here is a sample code:
<div id = "P">
<?php
$i=0;
$count=5;
while($i<$count){
$i++;
echo $ball;
}
?>
</div>
This code tells the server to print the code five times. I put this code in the bottom row of the previous table and now it looks like this.