Sort the $_POST variables
Posted
by Jerry
on Stack Overflow
See other posts from Stack Overflow
or by Jerry
Published on 2010-05-31T00:01:40Z
Indexed on
2010/05/31
0:12 UTC
Read the original article
Hit count: 148
Hello guys Might be an easy for you guys. I am trying to sort the $_POST variables that were sent by a form and update the sorted result in mysql. I am not sure how to do it and appreciate it anyone can help me about it.
My main.php
//I have a loop here. (omitted)
//$k will be increased by 1 every time the loop starts, so I will know the total times of the loops
//the form will be submitted to update.php
echo "<input type='hidden' name='pickTotal' value='".$k."' />";
echo "<input type='hidden' id='point' name='earnedPoint".$k."' value='".$point."' />";
echo "<input type='hidden' id='users' name='userName".$k."' value='".$userPick['user']."' />";
//loop ends
My update.php
if(isset($_POST['submit'])){
$pickTotal=$_POST['pickTotal']; //get the total loop
for ($p=0;$p<=$pickTotal;$p++){
$userToBeUpdated=$_POST['userName'.$p];
$userPoint=$_POST['earnedPoint'.$p];
//sort the $userPoint here.
//I need to find out who got the most points
//and list user's place. 1st, 2nd, 3rd...etc.
//update my mysql
}
Thanks for any helps.
© Stack Overflow or respective owner