text is truncated

This is a discussion on text is truncated within the PHP Language forums, part of the PHP Programming Forums category; Hi Hope that this is the correct newsgroup for this, sorry if it is not. I have the following code ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-04-2006
Derek @ Blueyonder
 
Posts: n/a
Default text is truncated

Hi

Hope that this is the correct newsgroup for this, sorry if it is not.

I have the following code which is used to display the data brought back
from a MySQL database in an input box so that a user cam make changes before
resubmitting them.

If I display $myrow[2] all of the text is there, if I use the following code
only the first word is show The same happens if I simply use $myrow[2] and
replace the $title altogether.

How do I get it to show all of the text please?

Many thanks



<?php
$title = $myrow[2] ;
echo ("<td colspan='2'><input name='title' type='text' size='100'
value=" . $title . "></td>");
?>


Reply With Quote
  #2 (permalink)  
Old 07-04-2006
Geoff Berrow
 
Posts: n/a
Default Re: text is truncated

Message-ID: <RUsqg.30253$181.2462@fe3.news.blueyonder.co.uk> from Derek
@ Blueyonder contained the following:

>If I display $myrow[2] all of the text is there, if I use the following code
>only the first word is show The same happens if I simply use $myrow[2] and
>replace the $title altogether.
>
>How do I get it to show all of the text please?


Does the entry contain quote marks?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
  #3 (permalink)  
Old 07-04-2006
Derek @ Blueyonder
 
Posts: n/a
Default Re: text is truncated


"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:csmka25cqf22udusthnhkbg8rhp2d4i7nq@4ax.com...
> Message-ID: <RUsqg.30253$181.2462@fe3.news.blueyonder.co.uk> from Derek
> @ Blueyonder contained the following:
>
>>If I display $myrow[2] all of the text is there, if I use the following
>>code
>>only the first word is show The same happens if I simply use $myrow[2] and
>>replace the $title altogether.
>>
>>How do I get it to show all of the text please?

>
> Does the entry contain quote marks?
>
> --
> Geoff Berrow (put thecat out to email)
> It's only Usenet, no one dies.
> My opinions, not the committee's, mine.
> Simple RFDs http://www.ckdog.co.uk/rfdmaker/


No


Reply With Quote
  #4 (permalink)  
Old 07-04-2006
Kimmo Laine
 
Posts: n/a
Default Re: text is truncated

"Derek @ Blueyonder" <derekblakeyNOSPAM@NOSPAMblueyonder.co.uk> wrote in
message news:S5tqg.30254$181.10037@fe3.news.blueyonder.co. uk...
>
> "Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
> news:csmka25cqf22udusthnhkbg8rhp2d4i7nq@4ax.com...
>> Message-ID: <RUsqg.30253$181.2462@fe3.news.blueyonder.co.uk> from Derek
>> @ Blueyonder contained the following:
>>
>>>If I display $myrow[2] all of the text is there, if I use the following
>>>code
>>>only the first word is show The same happens if I simply use $myrow[2]
>>>and
>>>replace the $title altogether.
>>>
>>>How do I get it to show all of the text please?

>>
>> Does the entry contain quote marks?
>>
>> --
>> Geoff Berrow (put thecat out to email)
>> It's only Usenet, no one dies.
>> My opinions, not the committee's, mine.
>> Simple RFDs http://www.ckdog.co.uk/rfdmaker/

>
> No



Try like this:
<input name='title' type='text' size='100' value='" . $title . "'/>

The entire title is printed to the field if you view the source code*, but
in html code all literal attributes must be delimited with quote marks. If
not, only the first word is used.


*) ALWAYS view the source code to see what is actually printed, the
html-representation might not be accurate, like in this case. It turns out
you're dealing with html problem, not php.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)


Reply With Quote
  #5 (permalink)  
Old 07-04-2006
Derek @ Blueyonder
 
Posts: n/a
Default Re: text is truncated


>>>>If I display $myrow[2] all of the text is there, if I use the following
>>>>code
>>>>only the first word is show The same happens if I simply use $myrow[2]
>>>>and
>>>>replace the $title altogether.
>>>>
>>>>How do I get it to show all of the text please?
>>>
>>> Does the entry contain quote marks?


>> No

>
>
> Try like this:
> <input name='title' type='text' size='100' value='" . $title . "'/>
>
> The entire title is printed to the field if you view the source code*, but
> in html code all literal attributes must be delimited with quote marks. If
> not, only the first word is used.
>
>
> *) ALWAYS view the source code to see what is actually printed, the
> html-representation might not be accurate, like in this case. It turns out
> you're dealing with html problem, not php.
>
> --
> "ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
> spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
>


Hi

Good one, that is working fine. And yes checking the source html it was
different to what was shown on the screen. Very strange.

Many thanks

Derek



Reply With Quote
  #6 (permalink)  
Old 07-05-2006
Kimmo Laine
 
Posts: n/a
Default Re: text is truncated

"Derek @ Blueyonder" <derekblakeyNOSPAM@NOSPAMblueyonder.co.uk> wrote in
message news:eBuqg.30261$181.10289@fe3.news.blueyonder.co. uk...
>
>>>>>If I display $myrow[2] all of the text is there, if I use the following
>>>>>code
>>>>>only the first word is show The same happens if I simply use $myrow[2]
>>>>>and
>>>>>replace the $title altogether.
>>>>>
>>>>>How do I get it to show all of the text please?
>>>>
>>>> Does the entry contain quote marks?

>
>>> No

>>
>>
>> Try like this:
>> <input name='title' type='text' size='100' value='" . $title . "'/>
>>
>> The entire title is printed to the field if you view the source code*,
>> but in html code all literal attributes must be delimited with quote
>> marks. If not, only the first word is used.
>>
>>
>> *) ALWAYS view the source code to see what is actually printed, the
>> html-representation might not be accurate, like in this case. It turns
>> out you're dealing with html problem, not php.
>>

>
> Hi
>
> Good one, that is working fine. And yes checking the source html it was
> different to what was shown on the screen. Very strange.


What's strange about browser not being able to display incorrect html? If
the code is corrupted like in this case it was, no wonder the browser cannot
correctly display it. That's why you should always alwasy make sure the html
your script produces is accurate, to make sure it's displayed correctly.


--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)


Reply With Quote
  #7 (permalink)  
Old 07-05-2006
Derek @ Blueyonder
 
Posts: n/a
Default Re: text is truncated


>> Hi
>>
>> Good one, that is working fine. And yes checking the source html it was
>> different to what was shown on the screen. Very strange.

>
> What's strange about browser not being able to display incorrect html? If
> the code is corrupted like in this case it was, no wonder the browser
> cannot correctly display it. That's why you should always alwasy make sure
> the html your script produces is accurate, to make sure it's displayed
> correctly.
>
>
> --
> "ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
> spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
>


You are correct, wrong HTML and the results will be unpredictable.

Now that I understand what I was doing wrong I have applied the same process
to a text area but this will not display any text at all, code below.

echo ("<td colspan='2'><textarea name='extract' cols='100' rows='5' value='
" . $myrow[3] . " '></textarea></td>");

Are text areas treated in a different way?

Any finaly if I may checkboxes, can values be loaded into them in the same
sort of way as you explained above? The code is

echo ("<td width='427'><input type='checkbox' name='childhood' value=" .
$myrow[27] ."></td>");

The value being loaded in is either a 1 or 0. I would like it to place a
tick in the checkbox if the value loaded is a 1.

As you have probably realised this is the first time since taking a basic
PHP course that I have used PHP, on the course everything always works OK
but this is real life!

I have googled and found several websites that do tutorials for PHP but none
seem to cover this requirement, does anyone know of any sites they could
recommend please.

Any help you could give is appreciated.


Reply With Quote
  #8 (permalink)  
Old 07-05-2006
Kimmo Laine
 
Posts: n/a
Default Re: text is truncated

Derek @ Blueyonder kirjoitti:
>>> Hi
>>>
>>> Good one, that is working fine. And yes checking the source html it was
>>> different to what was shown on the screen. Very strange.

>> What's strange about browser not being able to display incorrect html? If
>> the code is corrupted like in this case it was, no wonder the browser
>> cannot correctly display it. That's why you should always alwasy make sure
>> the html your script produces is accurate, to make sure it's displayed
>> correctly.
>>
>>
>> --
>> "ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
>> spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
>>

>
> You are correct, wrong HTML and the results will be unpredictable.
>
> Now that I understand what I was doing wrong I have applied the same process
> to a text area but this will not display any text at all, code below.
>


Textareas have no value attribute, instead, the value is placed between
the textarea tags like this:
echo ("<td colspan='2'><textarea name='extract' cols='100' rows='5'>" .
$myrow[3] . "</textarea></td>");

>
> Are text areas treated in a different way?
>
> Any finaly if I may checkboxes, can values be loaded into them in the same
> sort of way as you explained above? The code is
>
> echo ("<td width='427'><input type='checkbox' name='childhood' value=" .
> $myrow[27] ."></td>");


Yes indeed, that works. In case you sometimes need to checkbox checked
by default just insert the checked="checked" attribute in the tag.

Here's something you might find interesting:
http://www.w3.org/TR/html4/interact/forms.html the complete html 4.01
specification regarding forms.

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
Reply With Quote
  #9 (permalink)  
Old 07-05-2006
Geoff Berrow
 
Posts: n/a
Default Re: text is truncated

Message-ID: <A7Pqg.273829$8W1.180570@fe1.news.blueyonder.co.uk > from
Derek @ Blueyonder contained the following:

>You are correct, wrong HTML and the results will be unpredictable.
>
>Now that I understand what I was doing wrong I have applied the same process
>to a text area but this will not display any text at all, code below.
>
>echo ("<td colspan='2'><textarea name='extract' cols='100' rows='5' value='
>" . $myrow[3] . " '></textarea></td>");
>
>Are text areas treated in a different way?


Yes. The 'value' is whatever you put in between the tags
>
>Any finaly if I may checkboxes, can values be loaded into them in the same
>sort of way as you explained above? The code is
>
>echo ("<td width='427'><input type='checkbox' name='childhood' value=" .
>$myrow[27] ."></td>");
>
>The value being loaded in is either a 1 or 0. I would like it to place a
>tick in the checkbox if the value loaded is a 1.


To put tick in a checkbox you have to add the word 'checked'. You need
to write code to add this based on the value in your database. And
don't forget, checkboxes and radio buttons don't return a value unless
checked.
>
>As you have probably realised this is the first time since taking a basic
>PHP course that I have used PHP, on the course everything always works OK
>but this is real life!


Your PHP seems fine but your html sucks <g>.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:35 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0