0

I am trying to format a bunch of data into a nice looking table. I can get the query to work and show data, but when I try to add table tags, I get a white page of death. This code DOES NOT work and gives me the white screen of death:

if ($result->num_rows > 0) {
    echo "<table><tr><th>ID</th><th>Offline Status</th><th>Unit</th><th>Commodity</th><th>Shipper</th><th>Origin</th></tr>";
        // output data of each row
        while($row = $result->fetch_assoc()) {
            echo "<tr><td>" . $row["guid"]. "</td><td>" . " " .$row["offline"] . "</td><td>" . " " .$row["unit"] . "</td><td>". " ".$row["commodity"]."</td><td>". " ".$row["shipper"]."</td><td>". " ".$row["origin"]."</td></tr>";
        }
        echo "</table>;
    } else {
        echo "0 results";
    }

This code DOES work, but the results just appear on a line with spaces between and it looks awful:

if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            echo $row["guid"]. " ".$row["offline"]. " ".$row["unit"]. " ".$row["commodity"]. " ".$row["shipper"]. " ".$row["origin"]."<br>";
        }
    } else {
        echo "0 results";
    }

I'm pretty new to PHP and WAMP overall, so the solution may be pretty straightforward but any help is much appreciated!

hipnotyze
  • 11
  • 1

0 Answers0