I'm trying to loop this code as this will be dynamically generated. It's getting the number of rows from mysql and looping that many times. The POST is from ajax where it's also looped and it works perfectly. In the php part i'm not sure why it's not working. I've tried a lot of different loop variations.
$queryEle = "SELECT * FROM featureSheetContent WHERE `user_id` = '$userID' AND `feature_id` = '$featureID'";
$resultEle = mysqli_query($connect,$queryEle);
$rowEle = mysqli_num_rows($resultEle);
$i = 1;
while ($i < $rowEle) {
$eleID.$i = $_POST['eleID'.$i];
$eleID .= $eleID.$i;
$resizeWidth.$i = $_POST['resizeWidth'.$i];
$resizeWidth .= $eleID.$i;
$resizeHeight.$i = $_POST['resizeHeight'.$i];
$resizeHeight .= $eleID.$i;
$UploadMain = $connect->prepare("UPDATE featureSheetContent SET `ele_width` = ?, `ele_height` = ? WHERE id = ?");
$UploadMain->bind_param('sss', $resizeWidth, $resizeHeight, $eleID);
$UploadMain->execute();
$i++;
}
Unlooped code works:
$eleID1 = $_POST['eleID1'];
$resizeWidth1 = $_POST['resizeWidth1'];
$resizeHeight1 = $_POST['resizeHeight1'];
$eleID2 = $_POST['eleID2'];
$resizeWidth2 = $_POST['resizeWidth2'];
$resizeHeight2 = $_POST['resizeHeight2'];
$UploadMain = $connect->prepare("UPDATE featureSheetContent SET `ele_width` = ?, `ele_height` = ? WHERE id = ?");
$UploadMain->bind_param('sss', $resizeWidth1, $resizeHeight1, $eleID1);
$UploadMain->execute();
$UploadMain = $connect->prepare("UPDATE featureSheetContent SET `ele_width` = ?, `ele_height` = ? WHERE id = ?");
$UploadMain->bind_param('sss', $resizeWidth2, $resizeHeight2, $eleID2);
$UploadMain->execute();