php loops

doctorbill
doctorbill used Ask the Experts™
on
Code:
<?php
$result = mysql_query( "SELECT * FROM reminder_events ORDER BY reminder_date DESC" );
$nr = mysql_num_rows( $result );
if(empty($nr))
{
echo("
<tr>
<td colspan='3'>No Reminders setup</td>
</tr>
");
}
while( $row = mysql_fetch_array( $result ))
{
$reminder_name = $row["reminder_name"];
$reminder_desc = $row["reminder_desc"];
$reminder_date = $row["reminder_year"]."-".$row["reminder_month"]."-".$row["reminder_date"];
$reminder_id = $row["reminder_id"];

echo("

<tr>
<td width='20%' id=reminder_body_name>$reminder_name</td>
<td width='60%' id=reminder_body>$reminder_desc</td>
<td width='10%' id=reminder_body_date>$reminder_date</td>
<td width='10%'><a href='reminder_list.php?reminder_id=$reminder_id'>delete</a></td>
</tr>
");
}
mysql_free_result( $result );
?>

The above code is working fine but I am trying to introduce a double line break after each set oif results - ie after the line:
<td width='10%'><a href='reminder_list.php?reminder_id=$reminder_id'>delete</a></td>
</tr>
If I use the <br /> tag it is just appended to the top of the page
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
If you want a space after each set of results, simply add a blank Table Row (<tr>):

<tr>
<td width='20%' id=reminder_body_name>$reminder_name</td>
<td width='60%' id=reminder_body>$reminder_desc</td>
<td width='10%' id=reminder_body_date>$reminder_date</td>
<td width='10%'><a href='reminder_list.php?reminder_id=$reminder_id'>delete</a></td>
</tr>
<tr><td colspan='4'>&nbsp;</td></tr>

Open in new window

Dave BaldwinFixer of Problems
Most Valuable Expert 2014
Commented:
Chris is right.  You can not put a <br> in the middle of a 'table'.  <table>s and <tr>s and <td>s are containers and you can't put anything between them.  If you do, it gets put outside the table.  Somewhere.  All table content must go in the <td>s.
Brian TaoSenior Business Solutions Consultant
Top Expert 2014

Commented:
Wrap each set of results (in this case, each <tr>) in <table> tags to make them individual tables, and then put the <br> tags between tables.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
In addition to the above,

The mysql library has been deprecated as of PHP 5.5 http://php.net/manual/en/migration55.deprecated.php. You might want to consider moving to mysqli
$result = mysql_query( "SELECT * FROM reminder_events ORDER BY reminder_date DESC" );

Open in new window

Most Valuable Expert 2011
Top Expert 2016
Commented:
This doesn't have anything to do with formatting HTML tables, but Julian is right - MySQL is barely even on life support any more.  Get rid of it now, to avoid a catastrophe later.  Here's how to make the move away from the old, deprecated MySQL to one of the supported extensions.
http://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

Author

Commented:
Solved
Thanks for the advice

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial