Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP I want to demand my Array at my will
    primarykey
    data
    text
    <p>First off, I am a PHP NOOB. I am currently trying to develop a PHP page that is suppose to calculate a monthly budget for you and I am having problem with one section of it.</p> <p>I am having problem with my food variables. I can't give you the syntax I have for the "foodPerMonth" array because I simply don't know how to write it. Everything I've written so far is wrong.</p> <p>Anyhow. This is how I want it to work.</p> <p>I have my html form. I'm making it shorter just for the food part. You are suppose to type in how many i.e "Adult Woman" you want in your budget. And I will have a variable for each of those that will contain the cost per month for each person.</p> <pre><code>&lt;form action="function.php" method="post"&gt; &lt;label&gt;Adult Woman: &lt;/label&gt;&lt;input type="text" name="foodPerMonth[]" /&gt;&lt;br /&gt; &lt;label&gt;Adult Man: &lt;/label&gt;&lt;input type="text" name="foodPerMonth[]" /&gt;&lt;br /&gt; &lt;label&gt;Juvenile Girl: &lt;/label&gt;&lt;input type="text" name="foodPerMonth[]" /&gt;&lt;br /&gt; &lt;label&gt;Juvenile Boy: &lt;/label&gt;&lt;input type="text" name="foodPerMonth[]" /&gt;&lt;br /&gt; &lt;label&gt;Child Girl: &lt;/label&gt;&lt;input type="text" name="foodPerMonth[]" /&gt;&lt;br /&gt; &lt;label&gt;Child Boy: &lt;/label&gt;&lt;input type="text" name="foodPerMonth[]" /&gt;&lt;br /&gt; &lt;label&gt;Baby Girl: &lt;/label&gt;&lt;input type="text" name="foodPerMonth[]" /&gt;&lt;br /&gt; &lt;label&gt;Baby Boy: &lt;/label&gt;&lt;input type="text" name="foodPerMonth[]" /&gt;&lt;br /&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre> <p>What I want to know is how do I type this kind of array that will go with the form and etc.</p> <p>I would also appreciate if someone could thorougly explain how arrays and keys work and how they are used and what they are used for. Doesn't matter how much I read the fact in the manual. It wont stuck.</p> <p>Thank you in advance for answering, all help will be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload