Jump to content


Photo

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


  • Please log in to reply
1 reply to this topic

#1 Skelethor

Skelethor
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 10 April 2006 - 09:45 PM

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:

Name First Name E-mail Adres
-------------------------------------------------
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...

#2 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 10 April 2006 - 10:01 PM

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
<?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 }?>


Hope that this helps and if it works... woot! Solved one problem, good luck.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users