sweeti Posted May 16, 2012 Share Posted May 16, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/ Share on other sites More sharing options...
sweeti Posted May 16, 2012 Author Share Posted May 16, 2012 I tried a lot of things can you all help me out what to do.. Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1345926 Share on other sites More sharing options...
Jessica Posted May 16, 2012 Share Posted May 16, 2012 Restate the question more clearly. If you want all of the results in one row in your table, just change your HTML accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1345945 Share on other sites More sharing options...
ManiacDan Posted May 16, 2012 Share Posted May 16, 2012 the <tr> tag begins a new row. Take it out and you won't make new rows. That's all I can tell you without a more clearly defined question. Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1345970 Share on other sites More sharing options...
sweeti Posted May 17, 2012 Author Share Posted May 17, 2012 The problem is that i am getting result of 5 people's data.Hence i am getting 5 tables displayed one after another. What i want to do is display tables side by side. Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346237 Share on other sites More sharing options...
sweeti Posted May 17, 2012 Author Share Posted May 17, 2012 The problem is that i am getting result of 5 people's data.Hence i am getting 5 tables displayed one after another. What i want to do is display tables side by side. Please do let me know if you dint get my query..... Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346272 Share on other sites More sharing options...
cyberRobot Posted May 17, 2012 Share Posted May 17, 2012 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... Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346286 Share on other sites More sharing options...
sweeti Posted May 17, 2012 Author Share Posted May 17, 2012 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 . . Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346292 Share on other sites More sharing options...
cyberRobot Posted May 17, 2012 Share Posted May 17, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346298 Share on other sites More sharing options...
sweeti Posted May 17, 2012 Author Share Posted May 17, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346304 Share on other sites More sharing options...
cyberRobot Posted May 17, 2012 Share Posted May 17, 2012 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/>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346309 Share on other sites More sharing options...
sweeti Posted May 17, 2012 Author Share Posted May 17, 2012 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... Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346313 Share on other sites More sharing options...
sweeti Posted May 17, 2012 Author Share Posted May 17, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/262600-table-display-in-php/#findComment-1346314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.