Jump to content

[SOLVED] PHP Simple question


Aravinthan

Recommended Posts

Hi guys,

 

I have a problem and I dont know why it aint working.

 

Ok so, I have a page named step2.php

 

Which is the form that sends datas to the page named step3.php

 

Here is the code of step2.php:

 


$x = 1;

if ($receveur == 'Express Mistral')
{
$express_goals = $receveur_goals;
$express_pun = $receveur_pun;
}
else if ($visiteur == 'Express Mistral')
{
$express_goals = $visiteur_goals;
$express_pun = $visiteur_pun;
}

echo "<form action='step3.php' method='post' >";
echo "<table>";
echo "<thead>";
echo "<tr>";
echo "<th>Période</th><th>Temps</th><th>But</th><th>Assist</th><th>Assist</th><th>Extra(BN,DN,FO)</th>";
echo "</tr>";
echo "<tfoot><tr><td colspan='6'> </td></tr></tfoot>";
while ($express_goals >= $x)
{
echo "<tr><td><input type='textbox' name='periode_$x' /></td>";
echo "<td><input type='textbox' name='time_$x' /></td>";
echo "<td><select name='goal_$x' >";
$result = mysql_query("SELECT * FROM players ",$link);
			while($row = mysql_fetch_array($result))
			{
echo "<option value='" .$row['prenom']. "'>" .$row['prenom']. "</option>";
}
echo "</td>";
echo "<td><select name='assist1_$x' >";
$result = mysql_query("SELECT * FROM players ",$link);
			while($row = mysql_fetch_array($result))
			{
echo "<option value='" .$row['prenom']. "'>" .$row['prenom']. "</option>";
}
echo "<option value=''>Aucun</option>";
echo "</td>";
echo "<td><select name='assist2_$x' >";
$result = mysql_query("SELECT * FROM players ",$link);
			while($row = mysql_fetch_array($result))
			{
echo "<option value='" .$row['prenom']. "'>" .$row['prenom']. "</option>";
}
echo "<option value=''>Aucun</option>";
echo "</td>";
echo "<td><input type='textbox' name='extra_$x' /></td></tr>";
$x++;
}
echo "</table>";
echo "<input type='hidden' name='goals' value='$express_goals' />";
echo "<input type='hidden' name='pun' value='$express_pun' />";
echo "<input type='hidden' name='gameid' value='$gameid' />";
echo "<input type='submit' value='Continuer' />";
echo "</form>";

 

 

And here is the code for step3.php:

$gameid = $_POST['gameid'];
$express_goals = $_POST['goals'];
$express_pun = $_POST['pun'];

$x = 1;
while($express_goals >= $x)
{
$periode = $_POST['periode_$x'];
$time = $_POST['time_$x'];
$goal = $_POST['goal_$x'];
$assist1 = $_POST['assist1_$x'];
$assist2 = $_POST['assist2_$x'];
$extra = $_POST['extra_$x'];
mysql_query("INSERT INTO `boxscore` (periode, temps, but, assist1, assist2, extra, gameid) VALUES ('$periode', '$time', '$goal', '$assist1', '$assist2', '$extra', '$gameid')",$link);

echo "$goal";
echo "$x";
$x++;
}

 

 

But for some reason, There is no data inserted and the $goal doesnt show anything.

But the $x shows the numbers. Furthermore, When I change this to: $_POST['goal_$x']; to $_POST['goal_1'];

 

It shows the name of the player...

 

 

Any idea why $x is not working? And is there a way of inserting it?

Link to comment
Share on other sites

But the $x shows the numbers. Furthermore, When I change this to: $_POST['goal_$x']; to $_POST['goal_1'];

 

It shows the name of the player...

 

 

Any idea why $x is not working? And is there a way of inserting it?

 

Variable substitution only works in double quotes strings. Single quoted strings are evaluated literally.

 

http://dk.php.net/manual/en/language.types.string.php

Link to comment
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.