Jump to content

Blank lines in output


MADTinus
Go to solution Solved by ginerjm,

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();
 
?>
Edited by MADTinus
Link to comment
Share on other sites

  • Solution

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.