> -----Original Message-----
> From: stac...@comcast.net [mailto:stac...@comcast.net]
> Sent: Monday, November 08, 2010 7:41 PM
> To: php-general@lists.php.net
> Subject: [PHP] After parsing
> 
> The parse  worked great, got all the information I needed. Being so new to
> php, I am not sure how to get this information to display in an html  table so
> that I can style it...any suggestions would be greatly appreciated.  It 
> displays
> in my browser but I have not been able to figure out how to get it into a
> table on a page. (This is not the whole script, just wanted to show the
> portion to try to give a picture...of what I was working with...
> SimpleXMLElement.)
> 
> 
> 
> foreach ($guildxml->guildInfo->guild->members->children() as $char) {
>        if ( $char['level'] < 20 ) continue;
>     $toonrace    = return_race($char['raceId'], $char['genderId']);     //    
> Maps
> Race and Sex
>     $toonclass    = return_class($char['classId']);             // Maps class 
> name
>     $toonrank = return_rank($char['rank']);       //    Maps guild rank name
> 
>     $cch = curl_init();
>     curl_setopt ($cch, CURLOPT_URL, $charurl . $char['url']);
>     curl_setopt ($cch, CURLOPT_RETURNTRANSFER, true);
>     curl_setopt ($cch, CURLOPT_USERAGENT,  $browser_user_agent);
>     $charxml = curl_exec($cch);
>     $detailxml = new SimpleXMLElement($charxml);
> 
> 
>     echo '<b>Name:</b> <a href="' .$charurl . $char['url'] .'" 
> target="_blank">' .
> $char['name'] . '</a> ';    //Includes an armory external link
>     echo '<b>Class:</b> ' . $toonclass . ' ';
>     echo '<b>Race:</b>' . $toonrace . ' ';
>     echo '<b>Rank:</b> ' . $toonrank .' ';
>     echo '<b>Level:</b> ' . $char['level'] . ' ';         // Displays char 
> level
>     echo '<b>Professions: </b> ';
> 
>     foreach ($detailxml->characterInfo->characterTab->professions-
> >children() as $profession) {
>           if ($profession['name']=NULL) continue;
>           // Displays all of the professions and skill levels and maximums
>           echo $profession['name'] . ' (' . $profession['value'] . '/' .
> $profession['max'] .') ';
>     }
>     echo '<b>Specs: </b> ';
>     foreach ($detailxml->characterInfo->characterTab->talentSpecs-
> >children() as $spec) {
>           // Displays all of the specs in use and their builds and names.  It 
> is
> easily possible to show which one is active as well.
>           echo $spec['prim'] . '(' . $spec['treeOne'] . '/' . 
> $spec['treeTwo'] . '/'
> . $spec['treeThree'] . ')  ';
>     }
>     echo '<br>';
> }  ggestions?  The manual is a bit overwhelming, and I have searched for a
> solution, am really lost.

Create a table with a header.  In the header, put 'Name', 'Class', 'Race', 
'Rank', 'Level', 'Professions' in each column.  Then just loop through your 
data for each table row and put the data into the proper column accordingly.  
After the loop for the data, just close the table.

echo 
'<table><tr><th>Name</th><th>Class</th><th>Race</th><th>Rank</th><th>Level</th><th>Professions</th></tr>';
foreach () {
// data init 

echo '<tr>';
echo '<td>'.$char['name'].'</td>';
echo '<td>'.$toonclass.'</td>';
// etc...
echo '</tr>';
}
echo '</table>';

Regards,
Tommy


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to