I have the following php code but it only returns one row, I don't know why the table has 70 rows and the query asks for between two numbers, these numbers come from the form.
If I put 1 and 60 or 13 and 40 or something that is expected to return more than one row it always returns only the first row in the array$tables
require '../conn.php';
$from = $_POST['from'];
$to = $_POST['to'];
$sql = "SELECT * FROM senders WHERE id BETWEEN {$from} AND {$to}";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$response->sql = $sql;
$tables = array();
while($row = mysqli_fetch_assoc($result)) {
$table = new stdClass;
$table->id = $row['id'];
$table->name = $row['name'];
$table->work = $row['work'];
$table->domain = $row['domain'];
$table->email = $row['email'];
$table->emailEn = $row['emailEn'];
$table->date = $row['date'];
$table->qListDB = implode(" * ",json_decode($row['qListDB']));
$table->area = $row['area'];
$table->level = $row['level'];
$table->phone = $row['phone'];
$table->nameEn = $row['nameEn'];
$sql = "SELECT * FROM aplications WHERE ide = '{$row['ide']}'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$questSolved = [];
while($row = mysqli_fetch_assoc($result)) {
array_push($questSolved,$row['idUrl']);
$table->age = $row['age'];
$table->school = $row['school'];
}
$table->questSolved = $questSolved;
} else {
$table->age = " - ";
$table->school = " - ";
$table->questSolved = " - ";
}
array_push($tables,$table);
}
$response->state = true;
$response->tables = $tables;
echo json_encode($response);
} else {
$response->state = false;
echo json_encode($response);
}
I fixed it the problem was the names of the variables, I was using the same names in the two queries I had