I'm new to php and mysql, try to use mysql multi query function but it run many times. I couldn't find the logic need assistance.
The above mysql query are sample. Like this i have many "select sum()" statement with different condition. so I couldn't change the mysql to single query.
<html>
<title>MYsql</title>
<body>
<?php
require 'connection.php';
$query = "select count(first_name) as fName from employees;"; /* This is the sample mysql query (separate query with different condition) */
$query .= "select count(last_name) as lName from employees;";
$query .= "select count(title) as title from titles;";
$query .= "select count(first_name) as Name from employees";
/* Execute queries */
if (mysqli_multi_query($conn, $query)) {
do {
/* store first result set */
if ($result = mysqli_store_result($conn)) {
while ($row = mysqli_fetch_array($result))
/* print your results */
{ ?>
<div class="table" style="width: 50%; float:left; padding-top: 105px">
<table style="width: 70%"> <tr> <th colspan="2"> Lead Status </th> </tr>
<tr>
<td>First Name</td>
<td><?php echo $row[0]?></td>
</tr>
<tr>
<td>Last Name</td>
<td><?php echo $row[0]?></td>
</tr>
<tr>
<td>Title</td>
<td><?php echo $row[0]?></td>
</tr>
<tr>
<td>Total Counts</td>
<td><?php echo $row[0]?></td>
</tr>
</table> </div>
<?php
}
mysqli_free_result($result);
}
} while (mysqli_next_result($conn));
}
?>
</body>
</html>