Part I - Solved.
Hi, I'm trying to print some values on the screen from a table but I having a problem, I don't know much about string, vector and array but I think that my problem is related to them.
I'm getting this on the screen
Fatal error: Cannot use [] for reading ...
My code
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql) or trigger_error(mysql_error().$sql);
while($row = mysql_fetch_array($result)){
$DATA = $row[]; } //line with probelm
mysql_close();
//html part
<table>
<? foreach($DATA as $row): ?>
<tr>
<td><?=$row['id']?></td>
//more stuff
</tr>
<? endforeach ?>
</table>
What I'm trying to do is print somevalues form a database. But I'm getting this error.
I'm sorry for any mistake in English, and thanks in advance for any help.
Part II - Edited
Ok, seems like the mysql part is working, i used this before the html.
mysql_close();
echo "".$DATA[0][0];
To see if it's working and it printed the right value. But my html part is not printing right.
<html>
<body>
<h1>Lista de usuários</h1>
<table>
<? foreach($DATA as $row): ?>
<tr>
<td><?=$row['id']?></td>
<td><?=$row['nome']?></td>
//more stuff like this
</tr>
<? endforeach ?>
</table>
</body>
</html>
Can you help me? I'm sorry for any mistake in English, and thanks in advance for any help.