Hello everybody,
I'm trying to print out the mysql query result but I could manage to get only 1 row of data from the table. What am I doing wrong?
Please help me!
I'm just a beginner in Mysql or PHP and this is my first script.
$query = "select lname, fname from main" or die("Invalid query"
$result = mysql_query($query,$db);
$user_result = mysql_fetch_array($result);
for ($i = 0; $i<mysql_fetch_row($result); $i++) {
echo "Name: ".$user_result["fname"]. ",".$user_result["lname"];
}
I'm getting the following output:
Name: Jack, Fisher
But there are more than 1 row in a table.
I would greatly appreciate any help with this.
Thanks,
Irina
I'm trying to print out the mysql query result but I could manage to get only 1 row of data from the table. What am I doing wrong?
Please help me!
I'm just a beginner in Mysql or PHP and this is my first script.
$query = "select lname, fname from main" or die("Invalid query"
$result = mysql_query($query,$db);
$user_result = mysql_fetch_array($result);
for ($i = 0; $i<mysql_fetch_row($result); $i++) {
echo "Name: ".$user_result["fname"]. ",".$user_result["lname"];
}
I'm getting the following output:
Name: Jack, Fisher
But there are more than 1 row in a table.
I would greatly appreciate any help with this.
Thanks,
Irina