Tablo adı test, onu düzenleyin
$query = $db->query("SELECT modelKodu FROM test GROUP BY modelKodu")->fetchAll(2);
foreach ($query as $item) {
$q = $db->query("SELECT * FROM test WHERE modelKodu='{$item['modelKodu']}'")->fetchAll(2);
foreach ($q as $key => $value) {
$number = $key + 1;
$db->query("UPDATE test SET sss = '$number' WHERE id = '{$value['id']}'");
}
}
Merhaba aşağıdaki gibi düzenledim ama hata verdi.
Fatal error: Call to undefined method mysqli_result::fetchAll() in
$query = mysqli_query($con,"SELECT ModelKodu, COUNT(ModelKodu) as sayi FROM urunler GROUP BY ModelKodu HAVING COUNT(ModelKodu) > 1;")->fetchAll(2);
foreach ($query as $item) {
$q = mysqli_query($con, "SELECT * FROM urunler WHERE ModelKodu='{$item['ModelKodu']}'")->fetchAll(2);
foreach ($q as $key => $value) {
$number = $key + 1;
$sorgu3 = mysqli_query($con, "UPDATE urunler SET sss = '$number' WHERE id = '{$value['id']}'");
}
}