0
      $(document).ready(function(){
  $("#category").change(function(){
   var selectcat = $('#category').val(); 
  if(selectcat=="distribution"){
   <?php $page_select="is_distribution"; ?>
 }
 if(selectcat=="disc_man"){
  <?php $page_select="is_discmanufacturing"; ?>
 }
if(selectcat=="p_man"){
 <?php $page_select="is_pmanufacturing"; ?>
}
  if(selectcat=="erp_services"){
  <?php $page_select="is_erpservices"; ?>
 }
    if(selectcat=="crm_services"){
    <?php $page_select="is_crmservice"; ?>
 }
 if(selectcat=="others"){
 <?php $page_select="is_others"; ?>
 }
 });
  });

$table  = mysqli_query($conn ,'SELECT * FROM $page_select');
while($row  = mysqli_fetch_array($table)){ 

 <option value="<?php echo $row['item']; ?>"><?php echo $page_select; ?><? 
 php echo $row['item']; ?></option>

query shows 0 result. I want to access tablename from value. How i will print $page_select in mysqli query? I am taking value from javascript

user11093829
  • 1
  • 1
  • 4
  • PHP will not interpolate variables in single quoted strings. Change it to `"SELECT * FROM $page_select"` – Nick Mar 15 '19 at 05:21
  • i am taking the tablename from javascript. It will select different tablename according to the selected values. – user11093829 Mar 15 '19 at 05:29
  • It doesn't matter where the variable is coming from, PHP will not replace it inside single quotes. https://3v4l.org/mMenj – Nick Mar 15 '19 at 05:36
  • whenever i select different options it takes last value. And i want different table data on different selection – user11093829 Mar 15 '19 at 05:51
  • You need to read the other duplicate question I have just posted.https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming – Nick Mar 15 '19 at 05:54

0 Answers0