Monkuar Posted March 6, 2012 Share Posted March 6, 2012 //Update the ranks if (isset($_POST['update'])){ $ids = implode(",", array_map('intval', $_POST['m'])); $ranks = implode(",", array_map('intval', $_POST['ranks'])); if ($ids < 1) message("Incorrect Data"); if ($ranks < 0) message("Incorrect Data"); foreach ($_POST['ranks'] as $muffins){ $db->query('UPDATE friends set rank = '.$muffins.' WHERE friend_id = '.$_POST['m'].' AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); } redirect("s.php?section=Friends","Thanks, Ranks Updated"); } friend_id = becomes blank? the $muffins work and each rank is showed respectivaly, but how can I join in another array in the loop? I tried another foreach in the loop, but it just made me run double the queries. Any idea? $muffins is working fine and $_POST['m'] is giving no results i need to have 2 dynamic arrays in that forloop, the $ranks and the $ids Link to comment https://forums.phpfreaks.com/topic/258383-php-update-foreach-array-error/ Share on other sites More sharing options...
Monkuar Posted March 6, 2012 Author Share Posted March 6, 2012 fixed it foreach($_POST['ranks'] as $index=>$value) { $ranks = mysql_real_escape_string(TRIM($_POST['ranks'][$index])); $ids = mysql_real_escape_string(TRIM($_POST['m'][$index])); $db->query('UPDATE friends set rank = '.$ranks.' WHERE friend_id = '.$ids.' AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); } redirect("s.php?section=Friends","Thanks, Ranks Updated"); } Link to comment https://forums.phpfreaks.com/topic/258383-php-update-foreach-array-error/#findComment-1324463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.