Home  |  About  | Last |  Submit  |  Contact
AllQuests.com




Previous Question:  Rampage II extreme Core I7 940XE  Xtreme OverclockingNext Question:  [ubuntu] HP Officejet J6400 none working  Absolute Beginner Talk
Question array of undetermined length loop and count ( SitePoint Forums PHP )
Updated: 2010-07-21 05:50:02 (2)
array of undetermined length loop and count

Hi, I need to make a form where a person fills out their Name, DOB, and Email to register for an event. On the same page, I want to offer them to pay for 0-10 of their friends as well, filling out the same information.

So, I need the three fields and am assuming to put them into an array (other options?) ie <input name="Name[]" type="text">.

I need to access this information, by 1. how many items in this array to figure out a total cost, and 2, to loop through the array to insert the people into a mysql table.

How do I do these and is there a better way of going about this? I am pretty darn solid on php, however, am horrible with implementing arrays.

Answers: array of undetermined length loop and count ( SitePoint Forums PHP )
array of undetermined length loop and count

http://us3.php.net/manual/en/function.count.php
And...
http://us3.php.net/manual/en/control-structures.for.php

If you need more help, post the code you already have.

logic_earth

array of undetermined length loop and count

is it simiular to this:

PHP Code:

$first_name = $_POST["first_name"];

$last_name = $_POST["last_name"];
$dob = $_POST["dob"];
$email = $_POST["email"];
$gender = $_POST["gender"];

$ticket_count = $first_name;

echo
"Total Count:".$ticket_count."<br /><br />";
for(
$i*=*0;*$i*<*$ticket_count;*++$i) {
    echo
first_name[$i]."<br />";
    echo
last_name[$i]."<br />";
    echo
dob[$i]."<br />";
    echo
email[$i]."<br />";
    echo
gender[$i];
    echo
"<br /><br />";
}

webgodjj

Previous Question:  Rampage II extreme Core I7 940XE  XtremeSystems Forums  Xtreme OverclockingNext Question:  [ubuntu] HP Officejet J6400 none working  Ubuntu Forums  Absolute Beginner Talk

- Source: array of undetermined length loop and count SitePoint Forums PHP
- Previous Question: Rampage II extreme Core I7 940XE XtremeSystems Forums Xtreme Overclocking
- Next Question: [ubuntu] HP Officejet J6400 none working Ubuntu Forums Absolute Beginner Talk