0

I am trying to echo the results of two queries into a table. It seems to be splitting the results into separate rows rather than beside each other. The values for spaceid and venueid match in the db.

Here is my code:

 <?php
$con=mysqli_connect("host","username","pword","mydb");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql = "SELECT venue.venuename FROM venue INNER JOIN space ON space.spaceID=venue.venueID;";
$sql .= "SELECT space.room, space.costoftables FROM space INNER JOIN venue ON space.spaceID=venue.venueID;";
?>
<table class="tablesorter" width="600px" border="1" cellpadding="1" cellspacing="1" id="myTable">
<thead>
<tr>
<th>Venue Name</th>  <th>Room</th> <th>Cost</th>
</tr></thead><tbody>
<?php
// Execute multi query
if (mysqli_multi_query($con,$sql)){
  do{
      // Store first result set
    if ($result=mysqli_store_result($con)) {
      // Fetch one and one row
      while ($row=mysqli_fetch_array($result))
        {
        echo "<tr>";
        echo "<td>".$row['venuename']."</td>";
        echo "<td>".$row['room']."</td>";
        echo "<td>".$row['costoftables']."</td>";
        }
        ?>
        </tr>
        <?php

      }
    }
  while (mysqli_next_result($con));
}

mysqli_close($con);
?>
</tbody>
</table>

Here is the result: Results

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
sd0093
  • 13
  • 7

0 Answers0