title: How to use dynamic table in SQL query "Select * From $var; " $var is fetching from another file
body: <p>In below code i want to use $var as tablename, and the vale for $var is coming from another file. $var value is the name of table. So i want the dynamic tablenaame in sql query. but when i am executing following code then sql query is not taking $var value. But when i am declaring $var value in this file as static value then it is executing correctly. so please help me ...how to use variable as tablename in sql query.</p>
  
  <pre><code>include_once("set_team.php");
  // Create connection
  $conn = mysqli_connect($server, $username, $password, $database);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  
  ob_start();
  echo $table;
  $var = ob_get_clean();
  
  $sql = "SELECT * FROM $var";
  $res = mysqli_query($conn,$sql);
  $result = array();
  
  
  while($row = mysqli_fetch_array($res)){
  array_push($result,
  array('name'=&gt;$row[1]
  ));
  }
          echo json_encode(array("result"=&gt;$result));
  
  
  $conn-&gt;close();
  </code></pre>