i have this code in which i retreive jokes from database and show in table .problem is the result are being overlapped because m umable to change the top: attribute of table can anyone enlighten me with any idea so that i keeps every table at a distance of 20px from each other or a way that i can show data in an html table

<html>
 <body>


 <?php
 $username="root";
 $password="";
 $database="";

 mysql_connect('localhost',$username,$password);
 @mysql_select_db($database) or die( "Unable to select database");
 $query="SELECT * FROM jokes";
 $result=mysql_query($query);

 $num=mysql_numrows($result);

 mysql_close();
 ?>
 

 <?php
 
 $i=0;
 while ($i < $num) {
 $k=mysql_result($result,$i,"name");
 $j=mysql_result($result,$i,"content");
echo "<table border='1' cellpadding='0' cellspacing='0' style='position:absolute; left: 240px; top: 182px; width: 354px; height:20px;'><tr><td><center>";
echo $k;
echo "</center></td></tr></table>";
echo "<table border='1' cellpadding='0' cellspacing='0' style='position:absolute; left: 240px; top: 203px; width: 354px; height:100px;'><tr><td>";
echo $j;
echo "</td></tr></table>";

 $i++;
 } 
 ?>


</body>
 </html>

thanx help will be much appreciated

<html>
<head>
<style type="text/css">
.wrapper {  width: 700px; margin-top: 10px; border: 1px solid #DFDFDF; float: left; margin-left: 30px; }
.box{ width: 354px;  margin-left: 10px; margin-top: 20px; border: 1px solid #ddd; }
.margin { margin-top:20px; padding-left: 20px;}
</style>
</head>
 <body>


 <?php
 $username="root";
 $password="";
 $database="";

 mysql_connect('localhost',$username,$password);
 @mysql_select_db($database) or die( "Unable to select database");
 $query="SELECT * FROM jokes";
 $result=mysql_query($query);

 $num=mysql_numrows($result);

 mysql_close();
 ?>
 
<div class="wrapper">
<div class="box">
 <?php
 
 $i=0;
 while ($i < $num) {
 $k=mysql_result($result,$i,"name");
 $j=mysql_result($result,$i,"content");
echo "<div class='margin'>$k</div>";
echo "<div class='margin'>$j</div>";

 $i++;
 } 
 ?>

</div>
</div>
</body>
 </html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.