Good evening everyone, I created this file to be able to print the data from the database on the screen.
Everything ok but all the data contained in the database appear on the same line.
I would like them to print like this:

nome email titolo dataeora msg
nome email titolo dataeora msg
nome email titolo dataeora msg
etc. etc.

This is the code:


// dati di connessione al mio database MySQL
$db_host = 'localhost';
$db_user = 'xx';
$db_pass = 'xx';
$db_name = 'xx';

// connessione al DB utilizzando MySQLi
$cn = new mysqli($db_host, $db_user, $db_pass, $db_name);

// verifica su eventuali errori di connessione
if ($cn->connect_errno) {
    echo "Connessione fallita: ". $cn->connect_error . ".";

$query = "SELECT * FROM test";
$oggetto =$cn->query($query);

echo "<table><tr>";
echo "<th>nome</th><th>email</th><th>titolo</th><th>dataeora</th><th>msg</th>";
echo "</tr>";

<th><?php printf($scorri_oggetto['nome']);?></th>
<th><?php printf($scorri_oggetto['email']);?></th>
<th><?php printf($scorri_oggetto['titolo']);?></th>
<th><?php printf($scorri_oggetto['dataeora']);?></th>
<th><?php printf($scorri_oggetto['msg']);?></th>

echo "</table>";

// chiusura della connessione

what am I wrong? Can you fix me? Thanks

Recommended Answers

All 2 Replies

It looks like your code needs a rewrite as to lines 28 to 32 (tr and td versus th). (Not an offer to rewrite your code.)

The tutorial about table, tr, th and td is at

So after line 27 you would use tr and then your td (data) and then close the tr (/tr) after line 32.


  1. th = table header.
  2. tr = table row.
  3. td = table data.

TL;DR: The table has no data rows.

Thanks solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.