1. id team1 team2 home away tip
  2. ----------------------------------
  3. 12 xxx yyy zzz kkk
  4. 43 xxx yyy zzz kkk
  5. . . . . .
  6. . . . . .
  7.  
  8. $stmt = $db->prepare("SELECT id FROM tablename");
  9. $stmt->execute();
  10. $result=$stmt->fetchColumn();
  11. echo $result[0];
  12.  
  13. $stmt = $db->prepare("SELECT id FROM tablename");
  14. try{
  15. $stmt->execute();
  16. }catch(PDOException $err){
  17. //some logging function
  18. }
  19. //loop through each row
  20. while($result=$stmt->fetch(PDO::FETCH_ASSOC)){
  21. //select column by key and use
  22. echo $result['id'];
  23. }
  24.  
  25. $getUsers = $DBH->prepare("SELECT * FROM tablename ORDER BY id ASC");
  26. $getUsers->execute();
  27. $users = $getUsers->fetchAll();
  28.  
  29. $stmt = $db->prepare("SELECT id FROM tablename ORDER BY id ASC");
  30. $stmt->execute();
  31. $result = $stmt->fetchColumn();
  32. echo $result;
  33.  
  34. $stmt = $db->prepare("SELECT id FROM tablename");
  35. $stmt->execute();
  36. $result=$stmt->fetch(PDO::FETCH_NUM);
  37. echo $result[0];
  38.  
  39. <?php
  40.  
  41. $stmt =("SELECT id FROM tablename");
  42. $result=$db->prepare($stmt );
  43. $result->execute();
  44. while($row = $result->fetch(PDO::FETCH_ASSOC))
  45. {
  46. $id = $row['id'];
  47. echo $id;
  48. }
  49. ?>