Help with form post data and arrays


Posted on 16th Feb 2014 07:03 pm by admin

Hi all,

I am new to this forum... It has been awhile since i have worked with arrays, and i am starting to pull my hair out with this little issue i am having..

I hope someone can help me out with it, or even possibly show me a better way of doing this.

I am creating an web based hockey stats program for a ball hockey league.

I have a score sheet where they enter data. The score sheet gets constructed in a single form with a row for each player on the team. there are 12 players on each team so there will be 24 rows of data in the end.

I need to store each players game stats individually in a stats table where i can keep track of player game stats for each game.

here is the code for my form.

Code: while ($r_hmp = mysql_fetch_array($q_hm_play)) {
echo "<tr>";
echo "<td>".$r_hmp['jnum'] ."</td>";
echo "<td>".$r_hmp['lname'].", ".$r_hmp['fname']." ( ".$r_hmp['position'] ." )<input type='hidden' name='pid[]' value='".$r_hmp['id']."'></td>n";
echo "<td><input type='text' name='gp[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='g[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='a[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='pns[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='pim[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='gw[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='pg[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='sg[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='pa[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='sa[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='soa[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='sog[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='psa[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='psg[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='mj[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='mc[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='gm[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='gr[]' size='2' maxlength='2'></td>n";
echo "<td><input type='text' name='mt[]' size='2' maxlength='2'></td>n";
echo "</tr>n";
$hi++;
one the score keeper clicks the save button i am trying to create a multi-leveld array where i store 24 rows of data
each row should hold the players id and his particular stats for the game.

i tried to setup my array so i could loop troug it using two counters $player[$i][$x] where i would be the count of the row and x being the stat data.

here is the code i have tried, and to no avail.... your help with this would be greatly appreciated. I am sure there is a simple solution to this, but i am stuck and can't seem to find any info that might point me in the right direction.

thanks in advance

Code: $hmpc = count($_POST['pid']);
$i = 0;
while ($i <= $hmpc) {
$player = array($_POST['pid'],array($_post['gp']);
$i++;
}
$i = 0;
$x=0;
echo $hmpc;

while ($i < $hmpc) {
while ($x < $hmpc) {
echo 'Player Data: '.$player[$i][$x];
$x++;
}
$i++;

No comments posted yet

Your Answer:

Login to answer
78 Like 50 Dislike
Previous forums Next forums
Other forums

download directory onto C drive
I am attempting (if this is possible) to write a routine to automatically dump the contents of a dir

simplexml and xpath - Need some help
Hello,

I am trying to parse an xml which comes back from Amazon and I am trying to know how m

PHP - HTTP Digest Authentication - Understanding Code Help
Hi Everyone,

This is my first time on your website and please excuse if I am asking silly que

Removing Title From database problem
Hi again ! i am having an issue with updating database. When i update any price of a title it remove

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

gmdate() - want 1 hr before time
Hi,
I am using php gmdate().
Now I am entering all dates in my dbase using gmdate("Y-m-d

Unidentified index error in a simple form
I have been trying to make an HTML form that is handled by a PHP script. So far my attempts to get i

pls clear my confusion
Hi friends,

Pls solve my query .

what is the exact use of Scope Resolution Operator( i

Facebook status update API
Hello,

So, I'm trying to create my first Facebook application with PHP.

Basic ideas fo

PHP error (line 38) my website
Hello everyone, I'm new on this
and I got a web site thats got a error not showing the photos on<

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash