www.webdeveloper.com
Results 1 to 4 of 4

Thread: Php Table help

  1. #1
    Join Date
    May 2012
    Posts
    11

    Php Table help

    hello, i have xml file and parse data to php.

    my code is the following :

    Code:
    <?php
    error_reporting(0);
    $html = "";
    $url= "data.xml";
    $xml = simplexml_load_file($url);
    
    
    //metrame ta items (fylla) analoga me tin ekdosi php tou server
    
    if(phpversion() >= '5.3.0'){
        $bar_count = $xml->channel->item->count();
        }
    else    {
        $doc = new DOMDocument();
        $str = $xml->asXML();
        $doc->loadXML($str);
        $bar_count = $doc->getElementsByTagName("item")->length;
        }
    
    for($i =0; $i < $bar_count; $i++) { // dilono ton anotero arithmo (metrimena fylla) 
                $title = $xml -> channel -> item [$i] -> title;
                $date = $xml -> channel -> item [$i] -> pubDate;          
                $category = $xml -> channel -> item [$i] -> category;
                $author = $xml -> channel -> item [$i] -> author;  
                $link = $xml -> channel -> item [$i] -> link;
    			
    			
    echo "<table border='1'>";
               
    		   
    		   $html  .= "<center><tr><h3>$title : $date</h3>  <a href=$link > <img src=$link height='367' width='300' align='middle' border='0' /></a> </tr></center>";
    
    }
    
    echo "</table>";
    
    
    echo $html;
    
    echo $count 
    
    ?>
    code works fine but i have some problem to the output table. It "prints" each record above another but i need 3 records side by side and the next 3 above....


    Table with 3 columns

    any help appreciate

    thanks.

  2. #2
    Join Date
    May 2012
    Posts
    11
    edit : i found the solution <div style='float:left;

    hope to help someone else too...

    Chrisad
    Last edited by Chrisad; 05-08-2012 at 05:55 PM.

  3. #3
    Join Date
    Apr 2010
    Posts
    227
    LOL

    I was just thinking that I have no idea how your code can work at all.

    Effectively Im seeing you html looking like:

    <table>
    </table>
    <tr></tr>

    Which is completely screwed up lol.

  4. #4
    Join Date
    May 2012
    Posts
    11
    Quote Originally Posted by Belrick View Post
    LOL

    I was just thinking that I have no idea how your code can work at all.

    Effectively Im seeing you html looking like:

    <table>
    </table>
    <tr></tr>

    Which is completely screwed up lol.
    are you trying to maximize you post number (?), because i didnt see the reason of your post. Fisrt of all i post that i found the solution for my problem, so your opinion is useless, Second and last what is the benefit of this critical view... and bad aditute comments.

    ... get a life.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles