web 2.0

How to use PHP & Access (odbc) Random Rows Data

How to use PHP & Access (odbc) Random Rows Data This is tutorial  php developers how to using PHP connect to Microsft Access and ramdom data from table.

ShotDev Focus:
- PHP & Microsoft Access (Random data)

Example

php_access_random.php

  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?  
  7. $objConnect = odbc_connect("mydatabase","","");  
  8. $strSQL = "SELECT TOP 2 * FROM customer ORDER BY Rnd([CustomerID]) ";  
  9. $objExec = odbc_exec($objConnect$strSQLor die ("Error Execute [".$strSQL."]");  
  10. ?>  
  11. <table width="600" border="1">  
  12. <tr>  
  13. <th width="91"> <div align="center">CustomerID </div></th>  
  14. <th width="98"> <div align="center">Name </div></th>  
  15. <th width="198"> <div align="center">Email </div></th>  
  16. <th width="97"> <div align="center">CountryCode </div></th>  
  17. <th width="59"> <div align="center">Budget </div></th>  
  18. <th width="71"> <div align="center">Used </div></th>  
  19. </tr>  
  20. <?  
  21. while($objResult = odbc_fetch_array($objExec))  
  22. {  
  23. ?>  
  24. <tr>  
  25. <td><div align="center"><?=$objResult["CustomerID"];?></div></td>  
  26. <td><?=$objResult["Name"];?></td>  
  27. <td><?=$objResult["Email"];?></td>  
  28. <td><div align="center"><?=$objResult["CountryCode"];?></div></td>  
  29. <td align="right"><?=$objResult["Budget"];?></td>  
  30. <td align="right"><?=$objResult["Used"];?></td>  
  31. </tr>  
  32. <?  
  33. }  
  34. ?>  
  35. </table>  
  36. <?  
  37. odbc_close($objConnect);  
  38. ?>  
  39. </body>  
  40. </html>  

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_access_random.php

Screenshot

PHP Microsoft Access (Random Data From Table)
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.