TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-13-2009, 03:20 PM   #1 (permalink)
The Wanderer
 
Join Date: Mar 2009
Posts: 20
Thanks: 5
commonmind is on a distinguished road
Default How to stop table header from repeating

I'm trying to figure out how to stop some table headers from repeating.

PHP Code:
$xml = new SimpleXMLElement($rosterxml); 

foreach (
$xml->guildInfo->guild->members->children() as $char) {
    
    echo 
'
        <table><thead>
        
        <th>Name</th>
        <th>Race</th>
        <th>Class</th>
        <th>Level</th>
        <th>Rank</th>
        <th>Achievements</th>
        
        </thead>
        
        
        
        <tr>  
         <td class="roster">' 
$char['name'] . '</td> 
         <td class="roster">' 
$char['race'] . '</td>
         <td class="roster">' 
$char['class'] . '</td>
         <td class="roster">' 
$char['level'] . '</td>
         <td class="roster">' 
$char['rank'] . '</td>
         <td class="roster">' 
$char['achPoints'] . '</td>
         
      </tr> </table> '
;


Using the above code (I just took a guess as to how to setup the headers, obviously I was wrong), the header repeats along each row.
commonmind is offline  
Reply With Quote
Old 03-13-2009, 04:29 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

I think it's because you put the header inside the loop. try putting the headers before the loop.

PHP Code:
$xml = new SimpleXMLElement($rosterxml); 
echo 
'<table><thead>
        <th>Name</th>
        <th>Race</th>
        <th>Class</th>
        <th>Level</th>
        <th>Rank</th>
        <th>Achievements</th>
        
        </thead>'
;
foreach (
$xml->guildInfo->guild->members->children() as $char) {
    
    echo 
'<tr>  
         <td class="roster">' 
$char['name'] . '</td> 
         <td class="roster">' 
$char['race'] . '</td>
         <td class="roster">' 
$char['class'] . '</td>
         <td class="roster">' 
$char['level'] . '</td>
         <td class="roster">' 
$char['rank'] . '</td>
         <td class="roster">' 
$char['achPoints'] . '</td>
         
      </tr> '
;

}
echo 
'</table>'
tony is offline  
Reply With Quote
The Following User Says Thank You to tony For This Useful Post:
commonmind (03-13-2009)
Old 03-13-2009, 04:41 PM   #3 (permalink)
The Wanderer
 
Join Date: Mar 2009
Posts: 20
Thanks: 5
commonmind is on a distinguished road
Default

Thanks Tony, worked perfectly :)
commonmind is offline  
Reply With Quote
Old 03-13-2009, 08:11 PM   #4 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

No problem, glad I could help
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Databse structure Village Idiot TalkPHP Developer Team 3 01-16-2009 10:31 PM
This project has begun! Village Idiot TalkPHP Developer Team 40 01-01-2009 04:29 AM
Lookups table drewbee Advanced PHP Programming 0 07-15-2008 08:21 PM
Scrollable table with fixed header and left column maZtah Javascript, AJAX, E4X 0 11-14-2007 02:50 AM
The Dangers of the Header Function Wildhoney Absolute Beginners 3 09-18-2007 09:32 AM


All times are GMT. The time now is 07:25 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design