To answer your question, you could do something like this:
foreach($emp as $field => $value) {
echo '<textarea name="'.$field.'" cols="45" rows="5"
class="inputclass" id="'.$field.'">'.$value.'</textarea>';
}
The usual escaping needs to be applied.
Thanks,
Nathan.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Brendan Brink
Sent: Friday, 10 September 2010 9:24 a.m.
To: [email protected]
Subject: Re: [phpug] Including Form Field Name in PHP echo
thanks all for your suggestions...
however, i have an existing HTML forms already created, im just
wanting a quick way to echo contents from database into these fields:
ie. instead of on a per field basis, having echo $row['fieldname'];
want to have something like echo $row['this.name']; so that i can copy
and paste this code throughout all my forms, quicker to code...
hope this makes sense...but yes Zend is a great solution for creating new
forms.
On Fri, Sep 10, 2010 at 9:18 AM, S.Mohammed Alsharaf
<[email protected]> wrote:
> I use Zend_Form http://framework.zend.com/manual/en/zend.form.html
>
> Cheers
> Mohammed
> Blog: http://jamandcheese-on-phptoast.com/
> Email: [email protected]
> Mobile: 012 139 5924
>
>
>
>
>> Date: Fri, 10 Sep 2010 09:10:00 +1200
>> Subject: [phpug] Including Form Field Name in PHP echo
>> From: [email protected]
>> To: [email protected]
>>
>> Hi there,
>>
>> I am wanting to accomplish the following and wonder if possible and if
>> so, how to do it :)
>>
>> <textarea name="preferred_work" cols="45" rows="5" class="inputclass"
>> id="preferred_work"><?php echo $emp['preferred_work'];?></textarea>
>>
>> This works fine the above, but want to make it more dynamic, and
>> instead of hardcoding the field name from the $emp row, to capture the
>> name of the form field, using Java i guess, something like
>>
>> 'this.name'
>>
>> Reason is, I am trying to create more dynamic forms, and speed up coding
>> time.
>>
>> I realise that a better way would be to generate the entire form field
>> dynamically, and use PHP to echo the name of the field when creating
>> it, however the forms are already created and am wanting a quick way
>> to popular the fields with existing data from the database.
>>
>> hope this all makes sense :)
>>
>> Cheers
>> Brendan.
>>
>> --
>> NZ PHP Users Group: http://groups.google.com/group/nzphpug
>> To post, send email to [email protected]
>> To unsubscribe, send email to
>> [email protected]
>
> --
> NZ PHP Users Group: http://groups.google.com/group/nzphpug
> To post, send email to [email protected]
> To unsubscribe, send email to
> [email protected]
--
Kind Regards,
Brendan Brink
SMS Marketing Consultant | Manager
Sell2Cell Ltd.
021 0246 1646 | [email protected] | www.sell2cell.co.nz
We provide customized, cost-effective SMS & Web Solutions
Need a website? Need to integrate text-messaging into your business
or website? Contact us today for a free no-obligation quote!
VISIT OUR ASSOCIATED WEBSITES: textvouchers.com | textguru.co.nz
WARNING This email contains information which is CONFIDENTIAL and may
be subject to LEGAL PRIVILEGE. If you are not the intended recipient,
you must not peruse, use, disseminate, distribute or copy the email or
attachments. If you have received this in error, please notify us
immediately by return email, facsimile, or telephone (call us
collect).
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]