Part I - Solved.
Hi, I am trying to print some values โโon the screen from a table, but I have a problem, I know little about the string, vector and array, but I think my problem is related to them.
I get it on 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[]; }
mysql_close();
<table>
<? foreach($DATA as $row): ?>
<tr>
<td><?=$row['id']?></td>
</tr>
<? endforeach ?>
</table>
What I'm trying to do is print some values โโfrom a database. But I get this error.
I apologize for any mistake in the English language and in advance for any help.
Part II - Edited
Well, it looks like the mysql part is working, I used this before html. mysql_close(); echo "".$DATA[0][0];
To find out if it works, and printed the correct value. But my html part is not printing correctly.
<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>
Could you help me? I apologize for any mistake in English, and in advance for any help.