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 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.

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?

Sorry this is what it looks like…

Can you show us a link wehre this is at? It would be much easier to d ebug :slight_smile:

http://buggies4u.co.uk/administrator/

Thanks for having a look.

You need to add border-collapse:collapse to the CSS rule for the table.

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.

I’m getting a login form now. :confused:

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?

Hi, This is the PHP that I use for the form:

<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

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.

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.

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,

<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.../>.

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…