Text Field (multiline)

Links for php scripts

Moderators: macek, egami, gesf

kiwi
New php-forum User
New php-forum User
Posts: 124
Joined: Sun Feb 29, 2004 6:26 am
Contact:

Text Field (multiline)

Postby kiwi » Tue Aug 31, 2004 10:53 am

when i retrieve a value from database for a textfield (single line) i used this and it work:

<input name="title" type="text" id="title" size="30" VALUE="<?php print $qry[Title];?>">


when i to do the same thing for the textfield but for multiline: i try to use the same method:

<textarea name="message" cols="25" rows="5" id="message" value="<?php print $qry[Message];?>" ></textarea>

it does not work, why, can some one help me please, thanks

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Tue Aug 31, 2004 11:46 am

Two things:

a) When retrieving an array element by string index (e.g. "Message"), you need to put it in quotation marks just like any other string. Turn error_reporting to E_ALL and you'll see that this is throwing a notice:

Code: Select all

<?php
// This is wrong:
print $qry[Message];

// This is correct:
print $qry['Message'];
?>


b) HTML is a funny thing. Just like PHP, you actually have to use the correct syntax to make it work. The textarea tag does not have a "value" attribute. Its contents go between the closing and opening tag. Like this:

Code: Select all

<textarea name="message" cols="25" rows="5" id="message"><?php print $qry['Message']; ?></textarea>


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest