javascript - creating a table using php with js value

I am kind of a newbie, so bear with me. I am trying to show a div and within that is a table. The table data will be extracted using php. How the div would open is by clicking on a certain segment from my pie chart. I had it up and working but the way I coded it was inefficient. I tried changing it but it isn't working.
For more detail: I have a slider with months as the values (e.g: Slide 1 = January), the data shown in my pie chart is according to months showing delivery statuses (Delivered/Not Delivered) and upon clicking the segment it will show a table with the clients data who has their item delivered/not delivered.
So here is my table:
<div class="myTable" id="Dev">
<table id="tabs">
<thead>
<tr>
<th>Name</th>
<th>Condition</th>
<th>Type of Oat</th>
<th># of Oat</th>
<th>Status</th>
</tr>
</thead>
<tbody>
// Table data will be here
</tbody>
</table>
</div>
Here is a piece of code for the slider:
if(slideIndex == 1){
var month = "jan";
pie(month);
}
else if(slideIndex == 2){
var month = "feb";
pie(month);
}
Here is the piece of code where the segment is clicked and will show the div with the table:
var m = month // value passed from slider pie(month)
var OatChart = myChart.data.labels[clickedIndex];
if(OatChart == "Delivered"){
$("#Dev").show();
document.getElementById("tabs").innerHTML = <?php
$con = mysqli_connect("localhost","root","","oatdistribution");
$tabsql = "SELECT OatDis.Name, OatDis.LivingCondition, OatDis.OatType, OatDis.NoOfOats, '.$m.'.Status FROM OatDis INNER JOIN '.$m.' ON OatDis.Name = '.$m.'.Name WHERE '.$m.'.Status = 'Delivered'";
$data = mysqli_query($con,$tabsql);
while($row = mysqli_fetch_assoc($data)){
echo "<tr>";
echo "<td>" . $row['Name']."</td>";
echo "<td>" . $row['LivingCondition']."</td>";
echo "<td>" . $row['OatType']."</td>";
echo "<td>" . $row['NoOfOats']."</td>";
echo "<td>" . $row['Status']."</td>";
echo "</tr>";
} ?> ;
}else{ // same as above but status = "Not Delivered"
What I am trying to do is use the value I assigned when the slider changes to create the table. The value is the name of the table. I hope the question is understandable, Been through sleepless nights trying to figure this out. Something seems off with the code but I'm not sure what because the slider values are not showing, neither is the pie.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: mysqli::real_connect(): (hy000/2002): connection refused
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.