My php page is returning results before its asked to display results. I’m not sure why
Here is code :
Transaction list
Employee
<?php $dbc = mysqli_connect('localhost', 'root', 'root', 'xrentx') or die('I think that there might be something wrong. Maybe.'); // If statements if(isset($_POST['query'])){ if(isset($_POST['rental'])) { if(!empty($_POST['rental'])) { $rental_execute=$_POST['rental']; } else { $rental_execute = 0; } } if(isset($_POST['trans'])) { if(!empty($_POST['trans'])){ $trans_execute=$_POST['trans']; } else { $trans_execute = 0; } } if(isset($_POST['employ'])) { if(!empty($_POST['employ'])){ $employ_execute=$_POST['employ']; } else { $employ_execute = 0; } } } //Queries $rental_query="SELECT customer.last_name, customer.first_name, customer.phone_number, movie.movie_type, movie.title FROM customer, movie" ; $rental_execute=mysqli_query($dbc, $rental_query) or die('error'); $trans_query="SELECT order.date, customer.last_name, customer.phone_number, movie.title FROM `order`, customer, movie" ; $trans_execute=mysqli_query($dbc, $trans_query) or die('error2'); $employ_query="SELECT employee.first_name, customer.last_name, customer.first_name, customer.phone_number FROM employee, customer ORDER BY employee.last_name" ; $employ_execute=mysqli_query($dbc, $employ_query) or die('error3'); while ($row = mysqli_fetch_array($rental_execute)) { echo $row['last_name']; echo $row['first_name']; echo $row['phone_number']; echo $row['movie_type']; echo $row['title']; } while ($row = mysqli_fetch_array($trans_execute)) { echo $row['date']; echo $row['last_name']; echo $row['phone_number']; echo $row['title']; } while ($row = mysqli_fetch_array($employ_execute)) { echo $row['first_name']; echo $row['last_name']; echo $row['phone_number']; echo $row['first_name']; } mysqli_close ($dbc) ; ?>