I am facing unknown issue and don't know why code not running as I desire , the following code I am trying to make table with ID showgrd it's contents changes when month and day select tag specified and when click on button with ID reqbtn.
I tried but table contents didn't change when I clicked the button, but I noticed that the query runs and I displayed the contents in another div. Now I am trying these contents to be displayed in the table which it's contents already displayed with different select statement:
<?PHP
$execqr;
if($_POST['sepcefict']=='avail')
{
    switch($_POST['days'])
    {
        case "defd" : $_POST['days']="";
        break;
    }
    $execqr="SELECT sum(ordersreq.qual*strg_catgs.Disrate) as subtotal , storage.codename,storage.ID,storage.Scale_rate from ordersreq INNER JOIN strg_catgs INNER JOIN storage INNER JOIN orders on ordersreq.Cat_ID=strg_catgs.catID where strg_catgs.elemID = storage.ID and strg_catgs.descr='cwe' and ordersreq.link=orders.link and orders.Ordate like '2023-$_POST[months]-$_POST[days]%' GROUP BY codename;"; 
}
elseif(!$_POST['sepcefict'])
{
    $execqr="SELECT sum(ordersreq.qual*strg_catgs.Disrate) as subtotal ,  storage.codename,storage.ID,storage.Scale_rate from ordersreq INNER JOIN strg_catgs INNER JOIN storage on ordersreq.Cat_ID=strg_catgs.catID where strg_catgs.elemID = storage.ID and strg_catgs.descr='cwe' GROUP BY codename; ";
}
?>
<div id='Container' dir='rtl'>
<h1> جــرد الـمـخـزن  </h1>
<select id='months'>
<option  value='defm' selected disabled> اختر الشهر </option>
<?PHP
for($i=1;$i<13;$i++)
{
    ?>
    <option value='<?PHP if(strlen($i)>"1") {echo $i;} else {echo "0".$i;} ?>'> <?PHP echo $i; ?>  </option>
    <?PHP
}
?>
</select>
<select id='days'>
<option value='defd' selected disabled> اختر اليوم </option>
<?PHP
for($z=1;$z<32;$z++)
{
    ?>
    <option value='<?PHP if(strlen($z)>"1") {echo $z;} else {echo "0".$z;} ?>'> <?PHP echo $z; ?>  </option>
    <?PHP
}
?>
</select>
<button id='reqbtn' class='btns' onclick='shdet(0,1)' style="width:130px;height:50px;"> الــجــرد </button>
<h2> الـجـرد الـفـورى </h2>
<?PHP 
$getused=mysqli_query($conn,$execqr) or die("<p id='sd'>".print_r(mysqli_error($conn))."</p>");
?>
<table id='showgrd' class='ordtb' dir='rtl' border='1'>
<tr>
<th>
اسم الصنف
</th>
<th>
الاستخدام الكلي
</th>
</tr>
<?PHP
while($getdata=mysqli_fetch_array($getused))
{
    
    switch($getdata['Scale_rate'])
    {
        case "si" : $getdata['Scale_rate']="جـرام";
        break;
        case "qu" : $getdata['Scale_rate']="وحـده";
        break;
    }
    ?>
    <tr id='shgrdtr'>
    <td><?PHP echo $getdata['codename']; ?> </td>
    <td> <?PHP echo $getdata['subtotal']." ". $getdata['Scale_rate']; ?>  <span onclick='shdet(<?PHP echo $getdata['ID']; ?> , 0)' style="color:cyan;margin-right:20px;"> التفاصيل </span> </td>
    </tr>
    <?
}
echo "<table>";
<script>
function shdet(elemid, datedef) {
  var params;
  if (document.getElementById("months").value != "defm") {
    var months = document.getElementById("months").value;
    var days = document.getElementById("days").value;
    params += "&sepcefict=avail&months=" + months + "&days=" + days;
  }
  var nreq = new XMLHttpRequest();
  nreq.onreadystatechange = function() {
    if (document.getElementById("grdtbl")) {
      document.getElementById("grdtbl").remove();
    }
    if (nreq.readyState == "4" && nreq.status == "200") {
      var filterresp = nreq.responseText;
    }
  }
  nreq.open("POST", "http://localhost:8084/cashier/main.php?pg=grd", true);
  nreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  nreq.send(params);
  //alert(params);
  $(document).ready(function(e) {
    $(" #showgrd ").load("http://localhost:8084/cashier/main.php?pg=grd #showgrd #tr");
  });
}
</script>
I tried to make sure that query runs with ajax request and it runs
 
    