From the below code I need to display the values of data1. I have declared it by using id as "id="data1". Suggest me how to pass this "data1" as a variable in phpMysql.
<div class="col-lg-12">
<p id="data1"></p>
<?php
// Make a MySQL Connection
mysql_connect("localhost", "projects", "pwd", "projects") or die(mysql_error());
mysql_select_db("projects") or die(mysql_error());
$var='data1';
// Get all the data from the "Race" table and create table
$result2 = mysql_query("SELECT
A.service_center_name,
A.status,
C.branch_name
FROM
customers A
INNER JOIN
ascs B ON A.serv_cent_mob_no = B.contact_number
Inner Join
branches C on B.branch_id=C.id
where C.branch_name='". $var. "'
GROUP BY A.service_center_name ,A.status,C.branch_name;")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Service Center Name</th> <th>City</th> <th>Branches</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result2 )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['service_center_name'];
echo "</td><td>";
echo $row['branch_name'];
echo "</td><td>";
echo $row['status'];
echo "</td></tr>";
}
echo "</table>";
?>
</div>
How to pass the data1 using variable in the below code "$var='data1';".