I have some data in a mysql database.The database every time consists of a different number of rows.
An example of my table would be :
id team1 team2 home away tip
----------------------------------
12 xxx yyy zzz kkk
43 xxx yyy zzz kkk
. . . . .
. . . . .
So what i need to do is loop through every row of the table and be able to get the data from that row so i can create the tip.
I am a bit confused on how i could do that with pdo.
What i ve tried so far is try to get a column of data like this:
$stmt = $db->prepare("SELECT id FROM tablename");
$stmt->execute();
$result=$stmt->fetchColumn();
echo $result[0];
But even that , that i would expect to give me back the first id , which is 12 in this case, just returns me 1. Any ideas here?