SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: Help! Td Css

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Location
    Newark, Notts, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help! Td Css

    Hello Guys,

    Alot of help would be much appreciated.

    I have written some code to view some details from a database in a table.

    PHP Code:
    <?php foreach ($child as $childs): ?>
                      
                  <form action="" method="post">
                  
                      <tr>
                        <td><?php echo htmlspecialchars($childs['id'], ENT_QUOTES'UTF-8');?></td>
                        <td><?php echo htmlspecialchars($childs['firstname'], ENT_QUOTES'UTF-8');?>
                            <?php echo htmlspecialchars($childs['lastname'], ENT_QUOTES'UTF-8');?></td>
                        <td><?php echo htmlspecialchars($childs['f_first_name'], ENT_QUOTES'UTF-8');?> 
                            <?php echo htmlspecialchars($childs['f_last_name'], ENT_QUOTES'UTF-8');?></td>
                        <td><?php echo htmlspecialchars($childs['m_first_name'], ENT_QUOTES'UTF-8');?>
                            <?php echo htmlspecialchars($childs['m_last_name'], ENT_QUOTES'UTF-8');?></td>
                        <td><?php echo htmlspecialchars($childs['class'], ENT_QUOTES'UTF-8');?></td>
                        <td><input type="submit" name="action" value="Edit"></input></td>
                        <td><input type="submit" name="action" value="Invoice"></input></td>
                        <td><input type="submit" name="action" value="Account"></input></td>
                        <td><input type="checkbox" name="action" value="select"></input></td>
                      </tr>
                
                </form>
    I have written some CSS to chnage the way it looks and for some unknown reason to me I am unable to get it to render correctly, I know it is going to be me and not doing something but I can' put my finger on it.

    Code CSS:
    td {
    	background-color: #dcdcdc;
    	border-bottom: 1px solid #000;
    }

    And what I get is the first line all working fine and then the next lines not adhering to the css at all.

    Can someone please explain why?

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Location
    Newark, Notts, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    css.jpg

    Sorry this is what it looks like..

  3. #3
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,623
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Can you show us a link wehre this is at? It would be much easier to d ebug
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Location
    Newark, Notts, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://buggies4u.co.uk/administrator/

    Thanks for having a look.

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to add border-collapse:collapse to the CSS rule for the table.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Location
    Newark, Notts, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HI,

    I have done this and it hasn't made a difference. Not sure what that would do as the css rules are working for the first instance but not for the others.

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm getting a login form now.

    The PHP markup looks very, very odd. You seem to create one form for each row, which means the <form> tags are immediate children of the <table>, which is highly invalid markup!

    Instead of showing the PHP, and if the link is hidden behind a login, can't you copy and paste the generated HTML and the relevant CSS?
    Birnam wood is come to Dunsinane

  8. #8
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Location
    Newark, Notts, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, This is the PHP that I use for the form:

    PHP Code:
    <table>
                    <tr>
                        <th>ID</th>
                        <th>Child Name</th>
                        <th>Father Name</th>
                        <th>Mother Name</th>
                        <th>Class</th>
                        <th>Edit</th>
                        <th>Invoice</th>
                        <th>Accounts</th>
                        <th>Reports</th>
                      </tr>

    <?php foreach ($child as $childs): ?>
                      
                  <form action="" method="post">
                  
                      <tr>
                        <td><?php echo htmlspecialchars($childs['id'], ENT_QUOTES'UTF-8');?></td>
                        <td><?php echo htmlspecialchars($childs['firstname'], ENT_QUOTES'UTF-8');?>
                            <?php echo htmlspecialchars($childs['lastname'], ENT_QUOTES'UTF-8');?></td>
                        <td><?php echo htmlspecialchars($childs['f_first_name'], ENT_QUOTES'UTF-8');?> 
                            <?php echo htmlspecialchars($childs['f_last_name'], ENT_QUOTES'UTF-8');?></td>
                        <td><?php echo htmlspecialchars($childs['m_first_name'], ENT_QUOTES'UTF-8');?>
                            <?php echo htmlspecialchars($childs['m_last_name'], ENT_QUOTES'UTF-8');?></td>
                        <td><?php echo htmlspecialchars($childs['class'], ENT_QUOTES'UTF-8');?></td>
                        <td><input type="submit" name="action" value="Edit"></input></td>
                        <td><input type="submit" name="action" value="Invoice"></input></td>
                        <td><input type="submit" name="action" value="Account"></input></td>
                        <td><input type="checkbox" name="action" value="select"></input></td>
                      </tr>
                      
                          <td><input type="hidden" name="id" value="<?php echo $childs['id'];?>"/></td>
                
                </form>
                    
        </table>
    I have removed the login.. Sorry

  9. #9
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by newarkweb View Post
    Hi, This is the PHP that I use for the form
    Quote Originally Posted by AutisticCuckoo View Post
    Instead of showing the PHP, and if the link is hidden behind a login, can't you copy and paste the generated HTML and the relevant CSS?
    Why make it harder than necessary for us to help you?

    Anyway, from viewing the PHP it's quite clear that you are generating very bad markup. You can't have forms as immediate children of a table. With this type of invalid markup, all bets are off.

    FWIW, I still get the login form, even if I refresh.
    Birnam wood is come to Dunsinane

  10. #10
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Location
    Newark, Notts, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thank you for help anyway, I will go away and try and change the markup, I am new to PHP and need to learn alot. But thanks for your comments.

  11. #11
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to put the form around the table here. That will require some changes in your receiving app, probably, but it's the only way. Something along these lines,

    Code PHP:
    <form action="..." method="post">
      <table>
        <thead>
          <tr>
            <th>ID</th> 
            <th>Child Name</th> 
            <th>Father Name</th> 
            <th>Mother Name</th> 
            <th>Class</th> 
            <th>Edit</th> 
            <th>Invoice</th> 
            <th>Accounts</th> 
            <th>Reports</th> 
          </tr> 
        </thead>
       <tbody>
    <?php foreach ($child as $childs) { ?> 
          <tr> 
            <td><?php echo htmlspecialchars($childs['id'], ENT_QUOTES, 'UTF-8');?></td> 
            <td><?php echo htmlspecialchars($childs['firstname'], ENT_QUOTES, 'UTF-8');?> 
                <?php echo htmlspecialchars($childs['lastname'], ENT_QUOTES, 'UTF-8');?></td> 
            <td><?php echo htmlspecialchars($childs['f_first_name'], ENT_QUOTES, 'UTF-8');?> 
                <?php echo htmlspecialchars($childs['f_last_name'], ENT_QUOTES, 'UTF-8');?></td> 
            <td><?php echo htmlspecialchars($childs['m_first_name'], ENT_QUOTES, 'UTF-8');?> 
                <?php echo htmlspecialchars($childs['m_last_name'], ENT_QUOTES, 'UTF-8');?></td> 
            <td><?php echo htmlspecialchars($childs['class'], ENT_QUOTES, 'UTF-8');?></td> 
            <td><input type="submit" name="action" value="Edit"></td> 
            <td><input type="submit" name="action" value="Invoice"></td> 
            <td><input type="submit" name="action" value="Account"></td> 
            <td><input type="checkbox" name="action" value="select">
                <input type="hidden" name="id" value="<?php echo $childs['id'];?>"></td> 
          </tr>
    <?php } ?>
        </tbody>
      </table>
    </form>

    Don't use </input> end-tags unless you are really using XHTML (i.e., serving it as an application of XML). In pretend-XHTML served as HTML it may cause problems since those end-tags are invalid in HTML.

    If you use pretend-XHTML, then use <input.../>.
    Birnam wood is come to Dunsinane

  12. #12
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Location
    Newark, Notts, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats great mate, thank you very much fopr your help, it is much appreciated.. I have alot to learn I will get there one day..


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
  •