Hello,
I have successfully inserted records into a table called 'login'
How do I read and print out table records from database?
Pls go to http://www.tsldesigns.com/php/query-table.php
You will see a message.
here is my code.
what is wrong?
<?php
$table="login";
$connection=mysql_connect("localhost", "myadmin", "somepassword") or die("Could not connect...");
$db=mysql_select_db("tsl_db", $connection);
//your query
$sql="select * from $table";
$result=mysql_query($sql, $connection);
//initialize two arrays
$id=array();
$password=array();
//start while loop to store results of a query into arrays
while($res=mysql_fetch_array($result))
{
$id[]=$res["id"];
$password[]=$res["password"];
}
//start for loop to retrieve data from arrays
for($i=0; $i) {
//retrieve data
echo "$id[$i]";
echo "$password[$i]";
}
?>
I suspect something is wrong with retrieving data....and displaying it.
Pls help. Thanks
Su Lin
Ps. Email reply to sulin@tsldesigns.com