Displaying tables side by side
Hey all here i want to display my tables side by side in this form:
U_id:uid1 U_id:uid2
Name:name1 Name:name2
Team name: teamname1 Team name:teamname2
coins:coins1 coins:coins2
But some how my data gets displayed one after the other
U_id:uid1
Name:name1
Team name:teamname1
coins:coins1
U_id: uid2
Name:name2
Team name:teamname2
coins:coins2
i know that we can do this by using mod operator like
if($i%5==0)
{
echo "<table>'';
}
But despite doing this i am not getting right answer.Maybe i am assigning the mod operator at wrong place or is there any other method??????????
Code:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$data = array_keys($_POST);
$i = 1;
foreach($data as $d)
{
$sql = "SELECT * FROM tbl_default_player_blob WHERE uid=".$d;
$result = mysql_query($sql,$bd) or die(mysql_error());
$data= mysql_fetch_assoc($result);
if($i%5==0)
{
?>
<table style="padding-bottom:178px;">
<tbody>
<tr>
<th scope="row">U_Id :</th>
<td><?php echo ($data['uid']); ?></td>
</tr>
<tr>
<th scope="row">Name :</th>
<td><?php
/*$arr= json_encode($json);
echo $arr;*/
/*$json='{"name"}';*/
$json=($data['player_json_blob']);
$arr = json_decode($json,true);
echo $arr["name"];
?>
</td>
</tr>
<tr>
<th scope="row">Teamname:</th>
<td><?php
$json=($data['player_json_blob']);
$arr = json_decode($json,true);
echo $arr["teamname"];
?></td>
</tr>
<tr>
<th scope="row">Coins :</th>
<td><?php $json=($data['player_json_blob']);
$arr = json_decode($json,true);
echo $arr['coins'];?></td>
</tr>
<tr>
<th scope="row">Cash:</th>
<td><?php
$json=($data['player_json_blob']);
$arr = json_decode($json,true);
echo $arr['cash'];
?></td>
</tr>
</table>
<?php
}
$i++;
}
}
?>
You have a 5 instead of 2... you want to columns, right? I think you're also going to have to use CSS floats to get them side-by-side, or (eek) a parent table to create columns.
PHP Code:
if( $i % 2 == 0 ) {
echo '
<div style="float:left;">
<table>
....
</table>
</div>' ;
} else {
echo '
<div style="float:right;">
<table>
....
</table>
</div>' ;
}
Something to that effect, anyway.
"
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. "
-- Douglas Adams
http://www.chaoscontrol.org
Have you
minified your CSS/JS lately?
Originally Posted by
g0dzuki99
You have a 5 instead of 2... you want to columns, right? I think you're also going to have to use CSS floats to get them side-by-side, or (eek) a parent table to create columns.
PHP Code:
if( $i & #37; 2 == 0) { echo ' <div style="float:left;"> <table> .... </table> </div>' ; } else { echo ' <div style="float:right;"> <table> .... </table> </div>' ; }
Something to that effect, anyway.
hey thank you so much.The real problem was in my css i kept trying and never checked that..i used margin-top and margin-right and that was causing the problem and not letting my table to be displayed in desired manner.
<div style="float:left;">
this helped me lot.thank you.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks