Jump to content

Archived

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

Skelethor

How do I put a table around printed items of an mysql database?

Recommended Posts

This is what I want to do:

I have printed out my items of my database in 1 single line.
Every row in my database is a new line when it's printed out.

Like this:

Name, First Name, E-mail, Adres
Name2, First Name2, E-mail2, Adres2
...

Now I want to work with the lay-out.

Like this:

[b]Name First Name E-mail Adres[/b]
-------------------------------------------------
Mister X 1@mail Street 1
Mister Y 2@mail Street2

All this in a nice html table with border =1 (all different cells without the line under the headlines)

Here's my code:

<?php

$username="Administrator";
$password="********";
$database="newstravel";

mysql_connect('localhost',$username,$password);
mysql_select_db($database);

$query = 'INSERT INTO login VALUES("","'.$_POST['txtLoginnaam'].'", "'.$_POST['txtPaswoord'].'", "'.$_POST['txtVoornaam'].'", "'.$_POST['txtNaam'].'", "'.$_POST['txtAdres'].'", "'.$_POST['txtEmail'].'")';
$bInsert = mysql_query($query);
if(!$bInsert)
{
echo 'Fout tijdens invoegen';
}

$query="SELECT * FROM login";
$sqlResult=mysql_query($query);

while ($aUsers = mysql_fetch_assoc($sqlResult))
{
echo ' Loginnaam: '.$aUsers['Loginnaam'].' Paswoord: '.$aUsers['Paswoord'].' Voornaam: '.$aUsers['Voornaam'].' Naam: '.$aUsers['Naam'].' Adres: '.$aUsers['Adres'].' E-mail: '.$aUsers['E-mail'];
echo "<br>";
}
?>

Thx...

Share this post


Link to post
Share on other sites
Try making an incomplete table where the PHP loops the table rows that you want to display...

I'm will admit that this code might not work... but its the general idea that you want to build on
[code]<?php while ($aUsers = mysql_fetch_assoc($sqlResult)) {?>
  <tr class="td">
    <td><?php echo $aUsers['Naam']; ?></td>
    <td><?php echo $aUsers['Adres']; ?></td>
    <td><?php echo $aUsers['E-mail']; ?></td>
  </tr>
<?php }?>
[/code]


Hope that this helps and if it works... woot! Solved one problem, good luck.

Share this post


Link to post
Share on other sites

×

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.