2001-08-19 11:09:18 +00:00
|
|
|
<?xml encoding="iso-8859-1"?>
|
|
|
|
<!-- $Revision: 1.3 $ -->
|
2001-07-20 18:12:03 +00:00
|
|
|
<chapter id="faq.html">
|
|
|
|
<title>PHP and HTML</title>
|
|
|
|
<titleabbrev>PHP and HTML</titleabbrev>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
PHP and HTML interact a lot : PHP generate HTML, and HTML
|
|
|
|
has informations that will be sent to PHP.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<qandaset>
|
|
|
|
<qandaentry id="faq.html.arrays">
|
|
|
|
<question>
|
|
|
|
<para>How do I create arrays in a HTML <form>?</para>
|
|
|
|
</question>
|
|
|
|
<answer>
|
|
|
|
<para>
|
|
|
|
To get your <form> result sent as an array to your PHP script
|
|
|
|
you name the <input>, <select> or <textarea>
|
|
|
|
elements like this:
|
|
|
|
<programlisting>
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyArray[]">
|
|
|
|
</programlisting>
|
|
|
|
Notice the square brackets after the variable name, that's what
|
|
|
|
makes it an array. You can group the elements into different arrays
|
|
|
|
by assigning the same name to different elements:
|
|
|
|
<programlisting>
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyOtherArray[]">
|
|
|
|
<input name="MyOtherArray[]">
|
|
|
|
</programlisting>
|
|
|
|
This produces two arrays, MyArray and MyOtherArray, that gets sent
|
|
|
|
to the PHP script.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<emphasis>Note that you must not use indices with arrays in HTML!</emphasis>
|
|
|
|
The array gets filled in the order the elements appear in the form. For
|
|
|
|
functions you can use to process these arrays once you get them into
|
|
|
|
your scripts, please see the Arrays section in the manual.
|
|
|
|
</para>
|
|
|
|
</answer>
|
|
|
|
</qandaentry>
|
|
|
|
|
|
|
|
</qandaset>
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
-->
|