Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

2 problems on displaying database-data

Posted on 2002-06-22
11
Medium Priority
?
225 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
ID: 7102280
Really hard to answer without seeing some source???
0
 

Accepted Solution

by:
vk1981 earned 400 total points
ID: 7104350
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:Richard Quadling
Richard Quadling earned 400 total points
ID: 7106865
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:php_lady
ID: 7107486
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
 

Expert Comment

by:vk1981
ID: 7107548
Second problem:
Can i see this thml code?
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7107576
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
ID: 7107985
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:Richard Quadling
ID: 7108074
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
ID: 9643582
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

916 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