SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2003
    Location
    staffs
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    resultstables in php and css

    Hi every one
    Is there any one around that could give me advice on coding a web page in either in css or html to place the results out of my database in to there own styled <div>
    please!!
    and also many thanks to those who have replyed to any of my questions.
    Best regards

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    What kind of data are you trying to format? What do you want it to look like?

  3. #3
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Salt Lake City
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Highlight them!

    You could so something really simple to highlight the rows like this:

    CSS:
    Code:
    tr#light {background: white;}
    tr#dark {background: #666666;}
    HTML/PHP
    Code:
    <?
    // Where $row is a fetched array from the database result, and
    // where $num_rows is the number of rows in the database result.
    ?>
    
    <table>
    
    <?
    
    $color = "light";
    for ($i; $i <= $num_rows; $i++)
    {
       if ($color == "light")
       {
        $color = "dark";
       }
    
       echo "<tr id='".$color."'>";
    
       echo "<td>";
       echo $row['data1'];
       echo "</td>";
       echo "<td>";
       echo $row['data2'];
       echo "</td>";
    
       echo "</tr>";
    }
    
    </table>
    You should be able to modify this to something useful.
    Best,
    Whatknows
    Last edited by Whatknows; Sep 24, 2003 at 07:48. Reason: Glitch in thought!

  4. #4
    SitePoint Addict BenANFA's Avatar
    Join Date
    Apr 2003
    Location
    Bath, UK
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The $color = "light"; in the loop should be left out otherwise all the rows will be on a dark background

  5. #5
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Salt Lake City
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for pointing that out! I moved some code and forgot to delete from it's original spot. It is all fixed now.
    Last edited by Whatknows; Sep 24, 2003 at 07:49.


Bookmarks

Posting Permissions

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