title: Display data from two different tables using php
body: <p>I have got two tables in MySQL database, I want to use php to search in them, which I am able to do. however the problem is coming when I want to display data from table in my website. Those two tables have different field names and different number of fields. Is there any possibility to display rows by index or something like that. thanks a lot for your help.</p>
  
  <p>That's my code php code:</p>
  
  <pre><code> &lt;?php
  //variables to connect to db
  $servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "project";
  $lookingto = $_POST["sendTo"];
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  //getting user details from data base
  $sql = "SELECT * FROM ".$lookingto."";
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
  
      echo "&lt;table&gt;&lt;tr&gt;&lt;th&gt;Your search results&lt;/th&gt;&lt;/tr&gt;";
      echo "&lt;tr&gt;&lt;td&gt;&lt;h3&gt;Name&lt;/h3&gt;&lt;/td&gt;&lt;td&gt;&lt;h3&gt;ID&lt;/h3&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;";
      // output data of each row
      while($row = $result-&gt;fetch_assoc()) {
          echo "&lt;td&gt;".$row["make"]."&lt;/td&gt;&lt;td&gt;".$row["model"]."&lt;/td&gt;&lt;/tr&gt;";
          }
      echo "&lt;/table&gt;";
  
  } else {
      echo $lookingto;
      echo "No details found, please check your details and try again";
  }
  $conn-&gt;close();
  ?&gt;
  </code></pre>