Jump to content


Photo

Form Data


  • Please log in to reply
7 replies to this topic

#1 jd|

jd|
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 20 August 2006 - 08:06 PM

Hi all

This has been driving me crazy for a few days no matter what I do I can't get the result I want.

I have a table with a form on it. the form is loop for the number off Members (in my test this is 7)
and the user enters a score for each member.

The form then passes the data to a new page for proccessing. This is where it all falls to pieces.
I can see the data in the address bar but when I try any loop I can only ever display the last results.

the output should be

Mem=1 test = a
Mem=2 test = b
Mem=3 test = c etc...


Data being passed using "get" function on the form page.

show.php?Mem=1&point=a&Mem=2&point=b&Mem=3&point=c&Mem=5&point=d&Mem=6&point=e&Mem=7&point=f

Any ideas ?

Thanks

JD

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 August 2006 - 08:10 PM

In the $_GET array, because you are using the same variable name for each one of your members, it will overwrite it, so you end up with only the last one.

Try naming your inputs Mem[] and point[], which will create subarrays for each in the $_GET array.

#3 jd|

jd|
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 August 2006 - 06:05 PM

I have tried everything I know and I always get the last result in the table no matter what I do. Any other suggestions ?

JD

#4 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 24 August 2006 - 06:17 PM

Show your code, then at least we all see what you are talking about!

Ronald  8)
RTFM is an almost extinct art form, it should be subsidized.

#5 jd|

jd|
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 August 2006 - 06:37 PM

Hi I have tried several various ways of getting this to work and the, script to show it uses the "foreach" array but will not work !

its the $array[array] thats causing the problem. The data entered in the form can be any interger value. and the table/ form is variable depending on the number of members in the database.
Thanks

JD

$list = "<table border =\"1\"><tr><th>Forename</th>";
$list.= "<th>Surname</th>";
$list.= "<th>Handicap</th>";
$list.= "<th>Edit</th>";
$list.= "<th>Points</th></tr>";
$form ="<form action=\"show.php\" ";
$form.= "method =\"get\">";

                 while ($row= mysql_fetch_array($rs) )

                       {
                           $array = array('point'==$value);
                           $Mem = $row["Mem_Id"];
                           $list.= "<tr>";
                           $list.= "$test1";
                           $list.= "<td>".$row["Forename"]."</td>";
                           $list.= "<td>".$row["Surname"]."</td>";
                           $list.= "<td>".$row["Hcap"]."</td>";
                           $list.= "<td> <input type=\"text\" name=\"Mem\" value=\"$Mem\">  </td>";
                           $list.= "<td> <input type=\"text\" name=\"array\" value=\"$array[array]\"> </td>";

                      }

$list.= "</table>";
echo ($list);
                                       $form.= "<input type=\"submit\" value=\"Submit\">";
	                          $form.= "</form>";
	                         echo($form);

?>


#6 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 24 August 2006 - 07:22 PM

first of all your $list and $form are screwed up. If you look at the page and right click and select view source, you will see that you end up listing the form tag twice in which case you cancel out the first form tag. redo your form and try that

Ray

#7 jd|

jd|
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 August 2006 - 03:54 PM

Thanks Ray cleaned the code up for the form. Never even noticed it was doing that cause of the loop had been playing about with it so much to get the form to display properly.

Still no luck with getting the data the result from the form is...

show.php?Mem=1&array=a&Mem=2&array=b&Mem=3&array=c&Mem=5&array=d&Mem=6&array=e&Mem=7&array=f

And the below is the form page...

$list = "<table border =\"1\"><tr><th>Forename</th>";
$list.= "<th>Surname</th>";
$list.= "<th>Handicap</th>";
$list.= "<th>Edit</th>";
$list.= "<th>Points</th></tr>";
$list.="<form action=\"show.php\" ";
$list.="method =\"get\">";


while ($row= mysql_fetch_array($rs) )
{

$Mem = $row["Mem_Id"];

$list.= "<tr>";
$list.= "<td>".$row["Forename"]."</td>";
$list.= "<td>".$row["Surname"]."</td>";
$list.= "<td>".$row["Hcap"]."</td>";
$list.= "<td> <input type=\"text\" name=\"Mem\" value=\"$Mem\">  </td>";
$list.= "<td> <input type=\"text\" name=\"array\" value=\"$array[array]\"> </td>";

}


	
$list.= "</table>";

$list.= "<input type=\"submit\" value=\"Submit\">";
$list.= "</form>";
	echo($list);

?>


#8 jd|

jd|
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 27 August 2006 - 02:55 PM

Anyone else have any ideas as to where I'm going wrong with this one ?


Thanks

JD





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users