IRHM
IRHM

Reputation: 1326

Add Line Break In PHP Table

I wonder whether someone may be able to help me please.

I'm using the code below to create a table on my web page.

   <table id="report" width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
              <th width="150"></th>
          <th width="140"><div align="left">Location Name</div></th>
          <th width="398"><div align="left">Address</div></th>
              <th width="124"><div align="center">Finds Made</div></th>
              <th width="280"></th>
              <th width="101"></th>
              <th width="166"></th>
              <th width="90"></th>
        </tr>
        <?php

                        echo "<tr>
                                <td><div><a href='delete.php?locid=$lid'>Delete Location</a></div></td> 
                                <td><div align='left'>$lname</div></td>
                                <td><div align='left'>$laddress</div></td>
                                <td><div align='center'>$findscount</div></td>
                                <td><div><a href='viewlocation.php?locid=$lid'>View/Amend Location Details</a></div></td>  
                                <td><div><a href='addfinds.php?locid=$lid'>Add Finds</a></div></td> 
                                <td><div><a href='addfinds.php?locid=$lid'>Add Find Images</a></div></td>
                                <td><div><a href='finddetails.php?locid=$lid'>View Finds</a></div></td> 
                            </tr>";
                            echo "<th colspan=\"8\"><hr width=\"100%\"></th>";

What I'm trying to do and having problems with is to create a line break between each row of data, I'd like to place it before this line of my code: echo "<th colspan=\"8\"><hr width=\"100%\"></th>";

I've tried using "\n", echo "\n", "<br />" to name but a few, but I can't seem to get this to work.

I just wondered whether someone may be able to look at this please and let me know where I'm going wrong.

Many thanks and regards

Upvotes: 1

Views: 6368

Answers (3)

khaled_webdev
khaled_webdev

Reputation: 1430

 <tr><th colspan="8"><br/><hr width="100%"></th><tr>

Upvotes: 2

Jan Petzold
Jan Petzold

Reputation: 1571

I usually do it like this:

echo "<th colspan=\"8\"><hr width=\"100%\"></th>\r\n" .
     "<td></td>" .

...and so on.

Upvotes: 0

Paul
Paul

Reputation: 9022

Your <th> also needs a wrapping <tr>. Then add this to your css

th[colspan=8] { margin-top: 1em; }

Upvotes: 0

Related Questions