php - Select data from database with PDO -


I have some data in mysql database. The databases are each time a different number of rows are.

An example of my desk would be:

  ID Team 1 Team 2 Home Remote Tip ------------------ ------ ---------- 12 xxx yyy zzz kkk 43 xxx yyy zzz kkk . . . . . . . . .  

So what I have to do is loop through every line of the table and be able to get data from that line so that I can make a tip.

I'm a little confused about how I can do this with a peda.

I have tried so far, try to get a column of data like this:

  $ stmt = $ Db-> Prepare ("TableName with Selection ID"); $ Stmt- & gt; Executed (); $ Result = $ stmt-> FetchColumn (); $ Result reward [0];  

But also, I hope to return the ID first, which is 12 in this case, only gives me it. Any ideas here?

  $ stmt = $ db- & gt; Prepare ("Select IDF to Tableline"); {$ Stmt-> carry about (); } Hold (PDOException $ err) {// some logging functions} // while loop through each line ($ result = $ stmt-> Fetch (PDO :: FETCH_ASSOC)) {// key column Select and use the $ result for the result ['id']; }  

Alternatively, you can use fetchAll to select the entire dataset in a variable. Then you will not need a loop

There is a useful resource for the PDO:


Comments