Aravinthan Posted October 18, 2009 Share Posted October 18, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/178132-solved-php-simple-question/ Share on other sites More sharing options...
Daniel0 Posted October 18, 2009 Share Posted October 18, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/178132-solved-php-simple-question/#findComment-939221 Share on other sites More sharing options...
Aravinthan Posted October 18, 2009 Author Share Posted October 18, 2009 Ahhhh... tought something like that could be making this... But is there a work-around? Quote Link to comment https://forums.phpfreaks.com/topic/178132-solved-php-simple-question/#findComment-939232 Share on other sites More sharing options...
Daniel0 Posted October 18, 2009 Share Posted October 18, 2009 Yeah... use double quoted strings for accessing your array indices in this case Quote Link to comment https://forums.phpfreaks.com/topic/178132-solved-php-simple-question/#findComment-939235 Share on other sites More sharing options...
Aravinthan Posted October 18, 2009 Author Share Posted October 18, 2009 Of course.... Lol I cant beleive I asked you that question... Thanks daniel.... Seriously what was going on in my head Quote Link to comment https://forums.phpfreaks.com/topic/178132-solved-php-simple-question/#findComment-939240 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.