Jump to content

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


Skelethor

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...
Link to comment
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.
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.