Solved

2 problems on displaying database-data

Posted on 2002-06-22
11
217 Views
Last Modified: 2010-07-27
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,,,
0
Comment
Question by:php_lady
11 Comments
 
LVL 5

Expert Comment

by:Hamlet081299
Comment Utility
Really hard to answer without seeing some source???
0
 

Accepted Solution

by:
vk1981 earned 100 total points
Comment Utility
first problem:

I think u display text like this:
<input type=text value=<? echo $sometext; ?>

This is correct:
<input type="text" value="<?echo $sometext;?>">
or
echo "<input type='text' value='".$sometext."'>";

second problem:
I need more details about your problem...
0
 
LVL 40

Assisted Solution

by:RQuadling
RQuadling earned 100 total points
Comment Utility
If you are embedding the text into the value inside an <input> tag, you will need to watch out for " within the text as these will be though of as the closing " for the value property.

Try

echo "<input type='text' value='" . addslashes($sometext) . "'>";

Richard.
0
 

Author Comment

by:php_lady
Comment Utility
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 :)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:vk1981
Comment Utility
Second problem:
Can i see this thml code?
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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.

0
 

Expert Comment

by:vk1981
Comment Utility
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...

0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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.
0
 
LVL 11

Expert Comment

by:shmert
Comment Utility
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              
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now