Text Field (multiline)

Links for php scripts

Moderators: egami, macek, gesf

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

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
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

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

// 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>

Post Reply