Every job has its processes stored in a separate table, connected by the foreign key.
I want to select ids of jobs and then loop through processes by some criteria. But it returns me an error when I want to run another SQL query inside while loop.
Uncaught Error: Call to a member function bind_param() on bool
I checked the query in PHPMyAdmin and it worked.
$query=$conn->prepare("SELECT * FROM jobs");
$query->execute();
$result=$query->get_result();
$query->close();
while($row = $result->fetch_assoc()) {
$id=(int)$row['id'];
$query2=$conn->prepare("SELECT *FROM processes WHERE job_id=?");
$query2->bind_param('i',$id);
$query2->execute();
}
I know that the same job can be done in another way, but I want to know where is the error or what I am doing wrong here.
Thanks!