2001-08-19 11:09:18 +00:00
|
|
|
<?xml encoding="iso-8859-1"?>
|
2001-10-14 10:41:34 +00:00
|
|
|
<!-- $Revision: 1.5 $ -->
|
2001-07-20 18:12:03 +00:00
|
|
|
<chapter id="faq.html">
|
|
|
|
<title>PHP and HTML</title>
|
|
|
|
<titleabbrev>PHP and HTML</titleabbrev>
|
|
|
|
|
2001-10-14 10:41:34 +00:00
|
|
|
<para>
|
|
|
|
PHP and HTML interact a lot : PHP generate HTML, and HTML
|
|
|
|
has informations that will be sent to PHP.
|
|
|
|
</para>
|
2001-07-20 18:12:03 +00:00
|
|
|
|
|
|
|
<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>
|
2001-10-14 10:41:34 +00:00
|
|
|
<![CDATA[
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyArray[]">
|
|
|
|
]]>
|
2001-07-20 18:12:03 +00:00
|
|
|
</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>
|
2001-10-14 10:41:34 +00:00
|
|
|
<![CDATA[
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyArray[]">
|
|
|
|
<input name="MyOtherArray[]">
|
|
|
|
<input name="MyOtherArray[]">
|
|
|
|
]]>
|
2001-07-20 18:12:03 +00:00
|
|
|
</programlisting>
|
|
|
|
This produces two arrays, MyArray and MyOtherArray, that gets sent
|
|
|
|
to the PHP script.
|
|
|
|
</para>
|
|
|
|
<para>
|
2001-10-14 10:41:34 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
You need not use indices with arrays in HTML, although you can
|
|
|
|
specify number or associative indices, so you can exactly specify
|
|
|
|
what indices will contain the information provided by that
|
|
|
|
input element. If you do not specify indices, the array gets
|
|
|
|
filled in the order the elements appear in the form.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
For functions you can use to process these arrays once you get
|
|
|
|
them into your scripts, please see the
|
|
|
|
<link linkend="ref.array">Arrays section</link>.
|
2001-07-20 18:12:03 +00:00
|
|
|
</para>
|
|
|
|
</answer>
|
|
|
|
</qandaentry>
|
|
|
|
|
|
|
|
</qandaset>
|
|
|
|
</chapter>
|
|
|
|
|
2001-09-21 22:47:49 +00:00
|
|
|
<!-- 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:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|