Jump to content

Recommended Posts

Hey everyone,

I have a problem here.Now as u see my data is being displayed one after another in vertical manner.But what do i want to do is the entire table being displayed in same page continuously one after another in horizontal manner.how would i do that?

(below a screen shot is given how my table looks like.)

<code>

  <?php

        for($i=0;$i<=25;$i++)

        {

 

            if($i%5==0)

 

            {

                ?>

        <table>

            <tr>

                <th scope="row">U_Id :</th>

                <td><?php echo 'uid'; ?></td>

            </tr>

            <tr>

                <th scope="row">Name :</th>

                <td><?php

                    echo "name";

                    ?></td>

            </tr>

 

            <tr>

                <th scope="row">Teamname :</th>

                <td><?php

                    echo "teamname";

                    ?></td>

            </tr>

 

            <tr>

                <th scope="row">Coins :</th>

                <td><?php echo 'coins';?></td>

            </tr>

 

            <tr>

                <th scope="row">Cash:</th>

                <td><?php

                    echo 'cash';

                    ?></td>

            </tr>

        </table>

            <br/>

            <?php

                //echo "$i<br/>";

            }

 

        }

            ?>

</code>

post-132540-13482403516039_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/262600-table-display-in-php/
Share on other sites

So instead of:

 

U_Id: uid1
Name: name1
Teamname: teamname1
Coins: coins1
Cash: cash1

U_Id: uid2
Name: name2
Teamname: teamname2
Coins: coins2
Cash: cash2

...

 

 

Do you want?

 

U_Id:uid1uid2...

Name:name1name2...

Teamname:teamname1teamname2...

Coins:coins1coins2...

Cash:cash1cash2...

So instead of:

 

U_Id: uid1
Name: name1
Teamname: teamname1
Coins: coins1
Cash: cash1

U_Id: uid2
Name: name2
Teamname: teamname2
Coins: coins2
Cash: cash2

...

 

 

Do you want?

 

U_Id:uid1uid2...

Name:name1name2...

Teamname:teamname1teamname2...

Coins:coins1coins2...

Cash:cash1cash2...

 

What i exactly want is:

U_id:uid1                                        U_id:uid2                                                U_id:uid3   

Name:name1                                  Name:name2                                    Name:name3 

Team name:teamname1              Team name:teamname2                Team name:teamname3

coins:coins1                                    coins:coins2                                          coins:coins3 

.

.

Does the table orientation matter? After thinking a little more, it would be easier to do something like:

 

U_IdNameTeamnameCoinsCash

uid1name1teamname1coins1cash1

uid2name2teamname2coins2cash2

...............

 

 

Also, the above setup would be better for large data sets. The other way could get too wide to fit on the screen.

Does the table orientation matter? After thinking a little more, it would be easier to do something like:

 

U_IdNameTeamnameCoinsCash

uid1name1teamname1coins1cash1

uid2name2teamname2coins2cash2

...............

 

Also, the above setup would be better for large data sets. The other way could get too wide to fit on the screen.

 

Yes the orientation does matter..if it was in my hand i would do it like the way you were suggesting but i have to do it the way i have given here.

Yes the orientation does matter..if it was in my hand i would do it like the way you were suggesting but i have to do it the way i have given here.

 

 

You could try something like the following:

 

<?php
$uid_data      = '';
$name_data     = '';
$teamname_data = '';
$coins_data    = '';
$cash_data     = '';

for($i=0;$i<=25;$i++) {
if($i%5==0) {
	$uid_data      .= "<td>uid$i</td>";
	$name_data     .= "<td>name$i</td>";
	$teamname_data .= "<td>teamname$i</td>";
	$coins_data    .= "<td>coins$i</td>";
	$cash_data     .= "<td>cash$i</td>";
}
}

print '<table>';
print "<tr><th scope='row'>U_Id</th>$uid_data</tr>";
print "<tr><th scope='row'>Name</th>$name_data</tr>";
print "<tr><th scope='row'>Teamname</th>$teamname_data</tr>";
print "<tr><th scope='row'>Coins</th>$coins_data</tr>";
print "<tr><th scope='row'>Cash</th>$cash_data</tr>";
print '</table><br/>';
?>

Yes the orientation does matter..if it was in my hand i would do it like the way you were suggesting but i have to do it the way i have given here.

 

 

You could try something like the following:

 

<?php
$uid_data      = '';
$name_data     = '';
$teamname_data = '';
$coins_data    = '';
$cash_data     = '';

for($i=0;$i<=25;$i++) {
if($i%5==0) {
	$uid_data      .= "<td>uid$i</td>";
	$name_data     .= "<td>name$i</td>";
	$teamname_data .= "<td>teamname$i</td>";
	$coins_data    .= "<td>coins$i</td>";
	$cash_data     .= "<td>cash$i</td>";
}
}

print '<table>';
print "<tr><th scope='row'>U_Id</th>$uid_data</tr>";
print "<tr><th scope='row'>Name</th>$name_data</tr>";
print "<tr><th scope='row'>Teamname</th>$teamname_data</tr>";
print "<tr><th scope='row'>Coins</th>$coins_data</tr>";
print "<tr><th scope='row'>Cash</th>$cash_data</tr>";
print '</table><br/>';
?>

 

 

 

 

But the output is not coming as i desired.I was getting this out put earlier but not the kind of output i have given u as an example...

post-132540-13482403518049_thumb.png

This is the way it should come....

U_id:uid1                                        U_id:uid2                                                U_id:uid3 

Name:name1                                  Name:name2                                    Name:name3

Team name:teamname1              Team name:teamname2                Team name:teamname3

coins:coins1                                    coins:coins2                                          coins:coins3 

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.