Where did my Hard Returns go?

Where did my Hard Returns go?

am 01.03.2006 15:00:03 von Jeff Broomall

------=_NextPart_000_0014_01C63D0E.87271600
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Good morning.

I created an edit_task page that allows the user to edit tasks for the
database. I entered some text and used some hard returns.

But when I went to view the tasks (using a PHP script if it matters),
the hard returns didn't "take." None of em. All of the text is
jumbled together.

I checked within the MySQL database and noticed the Hard Returns show in =
the database (at
least while using phpMyAdmin).

Must have something to do with PHP? Where did I go wrong???

Thanks.

--Jeff
------=_NextPart_000_0014_01C63D0E.87271600--

Re: Where did my Hard Returns go?

am 01.03.2006 15:47:25 von Christoph Kunze

Jeff Broomall schrieb:
> Good morning.
>
> I created an edit_task page that allows the user to edit tasks for the
> database. I entered some text and used some hard returns.
>
> But when I went to view the tasks (using a PHP script if it matters),
> the hard returns didn't "take." None of em. All of the text is
> jumbled together.
>
> I checked within the MySQL database and noticed the Hard Returns show in the database (at
> least while using phpMyAdmin).
>
> Must have something to do with PHP? Where did I go wrong???
>
> Thanks.
>
> --Jeff
HTML doesn't care about "Hard Returns". I think you should transform
them into
. -> nl2br($text)

Hope that helps,
Chris

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Where did my Hard Returns go?

am 01.03.2006 17:34:25 von Jeff Broomall

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( '
$row['task_id'] . '">Edit
' . $row['task_task_no'] . '
' . $row['icaotask_no'] . '
' . $row['task_usaction'] . '



');

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.

Jeff
----- Original Message -----
From: "Jeff Broomall"
To:
Sent: Wednesday, March 01, 2006 9:00 AM
Subject: [PHP-DB] Where did my Hard Returns go?


Good morning.

I created an edit_task page that allows the user to edit tasks for the
database. I entered some text and used some hard returns.

But when I went to view the tasks (using a PHP script if it matters),
the hard returns didn't "take." None of em. All of the text is
jumbled together.

I checked within the MySQL database and noticed the Hard Returns show in the
database (at
least while using phpMyAdmin).

Must have something to do with PHP? Where did I go wrong???

Thanks.

--Jeff

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Where did my Hard Returns go?

am 01.03.2006 17:53:25 von Micah Stevens

You can't assign a value to a function! That's why attempt 1 didn't work.
Well, that and: The value returned by mysql_query is NOT a string, it's a
pointer to the values returned. You must fetch the string first to get the
column values out. This is why your third attempt was the only one that
actually had a chance of working.

However, nl2br doesn't insert any \n's, it inserts a
tag for every \n.
(actually
). I think that's what you meant, but it's helpful to be
specific.

If it's displaying 25 rows (12 + 13), then that's likely how many rows are
being returned by the database, you can check this by doing something like
this:

echo "

Number of rows returned by query: ".mysql_num_rows($result)."

";

before the table. If that displays 25, then your issue isn't your code, but
extra data in the table, which is what I suspect the problem is.

You also didn't close your while loop, but that's just a copy/paste error I
bet.

You can also create the table with border=1 and this will let you see actual
rows in the table, This loop will create 1 row for every row that's returned
fromthe database, hinting at your issue.

Hope that helps,
-Micah

On Wednesday 01 March 2006 8:34 am, Jeff Broomall 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( '
> > $row['task_id'] . '">Edit
> ' . $row['task_task_no'] . '
> ' . $row['icaotask_no'] . '
> ' . $row['task_usaction'] . '
>
>
>
> ');
>
> 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.
>
> Jeff
> ----- Original Message -----
> From: "Jeff Broomall"
> To:
> Sent: Wednesday, March 01, 2006 9:00 AM
> Subject: [PHP-DB] Where did my Hard Returns go?
>
>
> Good morning.
>
> I created an edit_task page that allows the user to edit tasks for the
> database. I entered some text and used some hard returns.
>
> But when I went to view the tasks (using a PHP script if it matters),
> the hard returns didn't "take." None of em. All of the text is
> jumbled together.
>
> I checked within the MySQL database and noticed the Hard Returns show in
> the database (at
> least while using phpMyAdmin).
>
> Must have something to do with PHP? Where did I go wrong???
>
> Thanks.
>
> --Jeff

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Where did my Hard Returns go?

am 01.03.2006 17:55:14 von Dwight Altman

Put nl2br() around the field in the table that you saved newlines
nl2br($row['theTableFieldWithTheNewlines'])

maybe
' . nl2br($row['task_usaction']) . '

-----Original Message-----
From: Jeff Broomall [mailto:news@broomall.us]
Sent: Wednesday, March 01, 2006 10:34 AM
To: Jeff Broomall
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Where did my Hard Returns go?

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( '
$row['task_id'] . '">Edit
' . $row['task_task_no'] . '
' . $row['icaotask_no'] . '
' . $row['task_usaction'] . '



');

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.

Jeff
----- Original Message -----
From: "Jeff Broomall"
To:
Sent: Wednesday, March 01, 2006 9:00 AM
Subject: [PHP-DB] Where did my Hard Returns go?


Good morning.

I created an edit_task page that allows the user to edit tasks for the
database. I entered some text and used some hard returns.

But when I went to view the tasks (using a PHP script if it matters),
the hard returns didn't "take." None of em. All of the text is
jumbled together.

I checked within the MySQL database and noticed the Hard Returns show in the

database (at
least while using phpMyAdmin).

Must have something to do with PHP? Where did I go wrong???

Thanks.

--Jeff

--

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Where did my Hard Returns go?

am 01.03.2006 18:18:43 von Philip Pryce

------=_Part_2537_7810883.1141233523005
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

You can't assign a value to a function!
that is actually incorrect, the list(); function assigns a value to a
functions vars.

--
~Philip Pryce

------=_Part_2537_7810883.1141233523005--

Re: Where did my Hard Returns go?

am 01.03.2006 18:34:47 von Micah Stevens

list() is a language construct.

On Wednesday 01 March 2006 9:18 am, Philip Pryce wrote:
> You can't assign a value to a function!
> that is actually incorrect, the list(); function assigns a value to a
> functions vars.
>
> --
> ~Philip Pryce

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Where did my Hard Returns go?

am 01.03.2006 18:36:47 von Dwight Altman

Like array(), this is not really a function, but a language construct.
list() is used to assign a list of variables in one operation.

http://php.he.net/manual/en/function.list.php

Watch out for those "language constructs" which look to us like functions.
Probably related to some folks preferring to write:
if (...
instead of
if(...

-----Original Message-----
From: Philip Pryce [mailto:philip.waters.pryce@gmail.com]
Sent: Wednesday, March 01, 2006 11:19 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Where did my Hard Returns go?

You can't assign a value to a function!
that is actually incorrect, the list(); function assigns a value to a
functions vars.

--

~Philip Pryce

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php