|
Posted by Jerry Stuckle on 03/01/06 18:40
ward@ wrote:
> As for an update...
>
> Through trial-and-error, I've determined the following don't work...
>
> Attempt 1:
>
> nl2br($result) = mysql_query ($query); // Run the query.
>
> Attempt 2:
>
> $result = mysql_query ($query); // Run the query.
> $result = nl2br($result)
>
> Attempt 3:
>
> $bg = '#eeeeee'; // Set the background color.
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
> $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the
> background color.
> echo nl2br( '<tr valign="top" bgcolor="' . $bg . '">
> <td align="left"><a href=edit_task.php?id=' .
> $row['task_id'] . '">Edit</a></td>
> <td align="left">' . $row['task_task_no'] . '</td>
> <td align="left">' . $row['icaotask_no'] . '</td>
> <td align="left">' . $row['task_usaction'] . '</td>
>
>
> </tr>
> ');
>
> Now, attempt 3 kind of worked. It did insert the \n but it almost
> doubled the size of the table. IOW, instead of 13 rows (the correct
> number of rows), it stated the table off with 12 empty rows
> (alternating between the two color shades) and then displayed the 13
> correct rows.
>
> Perhaps this was the proper placement of nl2br but there is something
> in the other code that screwed up the presentation???
>
> Thanks.
>
> Ward
Ward,
Just use nl2br() on the data from the database which has newlines not
the entire table, i.e.
echo '<tr valign="top" bgcolor="' . $bg . '">
<td align="left"><a href=edit_task.php?id=' .
$row['task_id'] . '">Edit</a></td>
<td align="left">' . $row['task_task_no'] . '</td>
<td align="left">' . $row['icaotask_no'] . '</td>
<td align="left">' . nl2br($row['task_usaction']) . '</td>
</tr>';
if only $row['task_usaction'] has the newlines.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|