Reputation: 55
I have a table in an html page, I must fill it with data taken from a MySQL database. I am new to PHP scripting and I have got the following code:
<div class="Table" >
<table >
<tr>
<td class="tab_sel">
-
</td>
<td class="tab_id">
Cod.ID
</td>
<td class="tab_name">
Nome
</td>
<td class="tab_cat">
Categoria
</td>
<td class="tab_price">
Prezzo al Pubblico
</td>
</tr>
<tr>
<td >
<input type="checkbox" name="html" value="html"/></input>
</td>
<?php include "config.php"; $data = new Mysqlclass();
$data->connetti(); $post_sql = $data->query("SELECT * FROM products ORDER BY id DESC");
if(mysql_num_rows($post_sql) > 0)
{while($post_obj = $Data->estrai($post_sql))
{$id=$post_obj->id;
$name = stripcslashes($post_obj->name);
$cat = stripcslashes($post_obj->category);
$price= stripcslashes($post_obj->price);
echo "<td>".$id."</td>"n;
echo "<td>".$name."</td>"n;
echo "<td>".$cat."</td>"n;
echo "<td>".$price."</td>"n;
}
}else{
echo"Tabella vuota";
}
$data->disconnetti()
?>
</tr>
But when I execute the page it shows the following error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\wamp\www\web-internal\pages\product.php on line 48.
Line 48 is the first echo: "<td>".$id."</td>"n
; .
I need help to fill the table, and if it is possible to fill all the row in the database.
Upvotes: 1
Views: 68
Reputation: 37233
you need to remove the n here
echo "<td>".$id."</td>"n;
to
echo "<td>".$id."</td>\n";
or
echo "<td>".$id."</td><br />";
Upvotes: 1
Reputation: 6837
You write
echo "<td>".$id."</td>"n;
but probably mean
echo "<td>".$id."</td>\n";
Upvotes: 2