Link to home
Start Free TrialLog in
Avatar of php_lady
php_lady

asked on

2 problems on displaying database-data

Hello all,

I have 2 problems today :)

I developed a MySql-PHP script that act mostly like php-nuke

put I had 2 problems
first : when I display a sentece of more than one word in a text box ==> only the first word is displayed ! but when I use another form obect like text area ==> the whole sentece is displayed .


Second : I allowed HTML code to be displayed in defualt .. but when I use <table> tag in the topics ==> there is a big white lines before the table ... and when I save the displayed page from my browser (File=>save) and then display it using front page ==> I see more colonms than I created using the <table> code .

I hope that I explain my problems correctly :) ... and I really hope that I can a real soluion to my problems :(

Thanks in advanced,,,
Avatar of Hamlet081299
Hamlet081299

Really hard to answer without seeing some source???
ASKER CERTIFIED SOLUTION
Avatar of vk1981
vk1981

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of php_lady

ASKER

Hello all :)

Thank you very much ... the first problem is solved now with your help :)

regarding the second problem .... here is sample code :
<?php
$mybody = stripslashes($row[lesbody]);
$mybody = nl2br($mybody);
echo $mybody;
?>

the problem is from the nl2br(); function .
I need it so when users enters new lines in the adding form , the text is displayed correctly with there lines .
is there any altirnative soluion ?
what should I do ?

and thanks all again :)
Second problem:
Can i see this thml code?
What is the wrapping property set to in the <textarea> on the original form.

This will control what is sent to the server initially.

<textarea wrap="physical"> will send you the line breaks which nl2br() can deal with, but if you put this back into a textarea for editing, put it in WITHOUT nl2br().

I think.

Try:

ex1:
<TEXTAREA>
<? echo str_replace ("<br>", "", $sometext); ?>
</TEXTAREA>

or

ex2:
<TEXTAREA>
<? echo str_replace ("<br />", "", $sometext); ?>
</TEXTAREA>

or

U must know how nl2br works... ;)
U should know how nl2br works, i.e. u should know what PHP really puts instead of '\n', if it puts '<br>' use ex1, if - '<br />' use ex2...

If you are storing the newlines you are sent from the client, then you only need to convert them to <br> if you intend to display the text OUTSIDE of a TEXTAREA; i.e. in normal HTML.

This textarea (the one I'm typing in right now) is set to wrap="virtual".

The will give all the line feeds and you can use nl2br when you want to put this on the screen (like all the comments here), but if you want to put it back into an edit field, you don't use nl2br. You do nothing except echo the field back to the user within <textarea> tags.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Split: vk1981/rquadling
Please leave any comments here within the next seven days.
               
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
               
Sam Barnum
EE Cleanup Volunteer