Jump to content

Blank lines in output


MADTinus

Recommended Posts

Hello there,

I've made a very simple file to put some requested data in a tabel-form. Somehow first the output starts with about 60-70 blank lines, and then the output. Somewere I made a mistake, but the longer I look, the harder it get tot see.

 

Please can someone show me the mistake. See below/

Thanks,

Martin.

 

Programlines:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<title>Output data from Complex</title>
</head>
 
 
<?php
 
# MRouw: deze file maakt de connectie met de database
require ('connectdb.php');
 
// MRouw: hier haal je de gewenste velden op uit de gewenste tabel
$sql = "SELECT Complexnaam, Adres, Plaats FROM complex";
$result = $conn->query($sql);
 
# Heater-row
echo "<table border=2 cellpadding=0 cellspacing=0>";
echo "<td><b>Complexnaam</b></td><td><b>Adres</b></td><td><b>Plaats</b></td>"; 
 
    while($row = $result->fetch_assoc()) {
        echo '
<tr>
            <td>' . $row['Complexnaam'] . '</td>
            <td>' . $row['Adres'] . '</td>
<td>' . $row['Plaats'] . '</td>
</tr>
<br>
    ';
;
    }
 
$conn->close();
 
?>
Link to comment
Share on other sites

You are seeing all the <br> tags echoed out first because you inserted them inside an html table. You can't do that.

 

This code:

<td>' . $row['Plaats'] . '</td>
</tr>
<br> THIS IS BAD
';
; THIS IS NOT NEEDED
}

 

should be changed to remove the <br> and the EXTRA ; line.

<td>' . $row['Plaats'] . '</td>
</tr>
';
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.