Hi
sorry about i m stucked in foreach loop
<?php
error_reporting(0);
$mysqli = new mysqli("localhost", "root", "root", "route");
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
$array = $_POST['arrayorder'];====>array of id s sent from form
$jour=$_POST['day'];======>array of days
$c=array_combine($array,$jour);
print_r(array_values($c));
if ($_POST['update'] == "update"){
//in my foreach i want to set value for position value got from count
//ex: day has for example 10 or more 1 day of the month
//i can have 1 position 1
1 position 2
1 position 3 and so
// when day passes to 2 the position must be 1 and so
// my problem the day is 2 but the position is conitnuation of the last day means 1
foreach ($c as $idval=> $value) {
$query = "UPDATE van SET week = '$count',position= '$count' WHERE id = '$idval' and day='$value' ";
if(mysqli_query($mysqli, $query)){
echo "";
$count ++;
} else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($mysqli);}
}
$count=1;
}
echo 'All saved! refresh the page to see the changes';
?>