Jump to content

Recommended Posts

Hi

 

I have 3 variables in a form and I am sending 3 instances of the variable from the form at a time into the arrays.

They are team name, team id and points.

 

I am trying to print those out (just to see what I've got) but can only print 2.  It seems like there is no value in the $Points array, but I can see that the value is being sent via the url. 

 

This is my test code

<?php
//database connection
include'myconnect.php';

$team_id[]=$_GET['team_id'];
$teamName[]=$_GET['teamName'];
$Points[]=$_GET['Points'];



foreach ($_GET['team_id'] as $row=>$name)

{

$team_id = $name;
$teamName = $_GET['teamName'][$row];
$Points = $_GET['Points'][$row];

echo "$name ";
echo"$teamName ";
echo '$Points <br>';
}


mysql_close();
?>

 

I don't understand why the $Points is not being printed out, although I admit that I'm learning this and it's like pulling teeth for me. 

 

 

The output I get is as below

 

5 Bristol Hotel $Points

22 Duke of Wellington $Points

40 Pontyates RFC $Points

 

I have tried with " and ' and have left the ' in to show the variable name being printed.

 

Any help would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/241745-arrays/
Share on other sites

Hi

 

Yes, I did put it in " " but that just didn't echo anything at all.  As I said in my post when I tried " " nothing echoed and when I use ' ' just $Points is printed.  If I don't put anything but echo $Points in nothing is printed.

 

It should output a number which I've entered using this form.  Is there something amiss with the form, perhaps.

 

<table width="30%" align="center"  border="1">
<form name="inputpoints" method="GET" action="checkresults3.php">
<tr>
<td width=40%>
<input type="char" name='team_id[]'size="2" value=" <? echo $row['team_id'];?>"></td><td>
<input type="text" name='teamName[]' size="36" value=" <? echo $row['teamName']; ?>"></td>
<td>
<SELECT name='points[]'>
<OPTION value=1>1</OPTION> 
<OPTION value=2>2</OPTION>
<OPTION value=3>3</OPTION>
<OPTION value=4>4</OPTION>
<OPTION value=0>0</OPTION><?php echo $row['Points'];?>"> 
</select>
</td>

 

As far as I can see from the url the values are being passed as shown.

[color=purple]checkresults3.php?team_id[]=+5&teamName[]=+Bristol+Hotel&points[]=4&team_id[]=+22&teamName[]=+Duke+of+Wellington&points[]=3&team_id[]=+40&teamName[]=+Pontyates+RFC&points[]=1[/color]

 

I will want to do further things with the information, but need to know that the values are there.

 

I appreciate your help, but I did try both methods and couldn't get anything out.

 

Harlequeen

Link to comment
https://forums.phpfreaks.com/topic/241745-arrays/#findComment-1242390
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.