You are here: Re: [PHP] Quickform - edit form « PHP « IT news, forums, messages
Re: [PHP] Quickform - edit form

Posted by Leonie on 10/07/14 11:10

Richard Lynch wrote:

> I always go for the "one form" system, because otherwise you have double
> the work to do (opening two files) every little change, and invariably one
> of the forms drifts out of sync when (not if, when) you forget to change
> the other form and...

Thanks, Robert. I think this is the best way too. As the app I'm
working on is still in development no doubt the form will be changing a
few times.


> Assigning data to the form mostly consists of using the VALUE= attribute
> in HTML tags, except TEXTAREA where it goes between opening/closing tag.
>
> Basic logic flow:
>
> <?php
> if (...){ //Detect some indicator that you want a "new_record"
> $query = "insert ...";
> $record_id = mysql_insert_id(...);
> }
> else{
> //initialize all fields to blanks:
> $name = '';
> $address = '';
> }
>
> $record_id = isset($record_id) ? $record_id : $_REQUEST['record_id'];
> if (...){ //detect some indicator that you want to "update" a reocrd
> $query = "update ...";
> }
>
> $query = "select ... where id = $record_id";
> ?>
> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
> //form data here
> </form>
>
> Yes, you display the form again with the data to edit, right after an insert.
>
> That's by DESIGN, since it will help catch "ooops!" on data entry by
> re-confirming with the user what they just did. Better data entry is
> good.
>
Thanks for that code. It looks good.

I'm using Pear QuickForm (Pear DB for database) to create the forms,
passing it to a Smarty template. I'm just a bit stumped as to how to
get the data into Quickform.

Snippet of field creation:

$form->addElement('text', 'year', 'Year:');

Leonie

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация