You are here: Re: Editable forms with 1000 elements « PHP Programming Language « IT news, forums, messages
Re: Editable forms with 1000 elements

Posted by Erwin Moller on 05/19/06 13:04

Luke wrote:

> Hi! I am new to PHP but I am a very experienced in Perl/CGI/templates.
>
> I work in medical informatics when we deal with very large data
> collection forms. Some of them have over 1000 elements! Forms are not
> outputted by PHP, they are designed by nurses using various visual HTML
> editors /drag & drop/.
>
> Ok, it is relatively easy to get all the fields submitted into the
> MySQL server. But there is always a chance of a data entry error or a
> form has to be printable (as it looks when being filled out, with all
> visual elements). It means we have to retrieve all values and present
> them on the screen (ready to be resubmitted).
>
> So I wonder what would experienced PHP users do here. Are there any
> special Classes/modules that would take an html file and insert the
> values into corresponding <input> elements? Or anything what could make
> my life easier?
>
> Or is it really the only way to get it worked to place 1000 <?php echo
> "value=$value" ?> inserts in my HTML code?
>
> That's a VERY TEDIOUS WORK!!!

Hi Luke,

That question is hard to answer without knowing the underlying datastructure
(databaseschema).

Are all the elements text?
Do you need SELECT-boxes too? Or radiobuttons? etc.
All need a special way to handle (But not complex).

If you only have textelements I would approach it like this:

If you have some tables like:
[psuedocode]
CREATE TABLE tblelements(
elementid SERIAL PRIMARY KEY,
formid integer REFERENCES tblform(formid),
elementname text,
elementvalue text
)

CREATE TABLE tblform(
formid SERIAL PRIMARY KEY,
fromname text
)

[/pseudocode]

Now you can produce easily an automated form like:
(I only use Postgres, so you'll have to translate this to mysql yourself)
[pseudocode like ADODB]

<?
// which form?
$wantedFormid = 12;
?>

<form action="receiveform.php" METHOD="POST">
<input type="hidden" name="formid" value="<?= $wantedFormid ?>">
<table border=1>
<?
$SQL = "SELECT elementid, elementname, elementvalue FROM tblelements WHERE";
$SQL.= " (formid=$wantedFormid);";
$RS = $connection->Execute($SQL)->getArray();
$numrows=count($RS);
for($i=0;$i<$numrows;$i++){
$row=$RS[$i];
?>
<tr>
<td>
<?= $row["elementname"] ?>
</td>
<td>
<input type="text" name="elementid<?= $row["elementid"] ?>"
value="<?= htmlentities($row["elementvalue"]) ?>">
</td>
</tr>
<?
}
?>
<tr>
<td colspan=2>
<input type="submit">
</td>
</tr>
</table>
</form>

[/pseudocode]

(not tested)

For more complex sturctures, like radiobuttons, you need of course
additional tables.

> Thanks,
> Luke


Hope this helped.

Regards,
Erwin Moller

 

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

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