473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

PHP Database Programming

I'm just learning PHP. I would like to know if database programming in PHP can be done using MS-Access. Can any one help me with complete example codes please.
Nov 3 '05 #1
1 2801
Niheel
2,460 Expert Mod 2GB
Here is sample code on a connection. Tested on WinXP, works fine.

Expand|Select|Wrap|Line Numbers
  1. <?
  2. // url to database file
  3. $db = 'C:\\Program Files\\Microsoft Office\\Office\\Samples\\Northwind.mdb';
  4.  
  5. // adodb connection
  6. $conn = new COM('ADODB.Connection');
  7. $conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
  8.  
  9. // sql code
  10. $sql = 'SELECT ProductName, QuantityPerUnit, UnitPrice
  11. FROM     Products
  12. ORDER BY ProductName';
  13. $rs = $conn->Execute($sql);
  14.  
  15. // html
  16. ?>
  17. <table>
  18. <tr>
  19. <th>Product Name</th>
  20. <th>Quantity Per Unit</th>
  21. <th>Unit Price</th>
  22. </tr>
  23. <? while (!$rs->EOF): ?>
  24. <tr>
  25. <td><?= $rs->Fields['ProductName']->Value ?></td>
  26. <td><?= $rs->Fields['QuantityPerUnit']->Value ?></td>
  27. <td><?= $rs->Fields['UnitPrice']->Value ?></td>
  28. </tr>
  29. <? $rs->MoveNext() ?>
  30. <? endwhile ?>
  31. </table>
  32. <?
  33. $rs->Close();
  34. $conn->Close();
  35. ?>
  36.  
Nov 18 '05 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: A Cate | last post by:
I am new to PHP. I am trying to develop a web site on a development machine that needs to access data in a mysql database. I have mysql running on my development machine with a copy of the...
0
by: John Davis | last post by:
I always heard the term "data/database driven programming" model in ASP database, SQL programming, and web programming circles. But I don't quite sure what does it mean? Does it mean the web...
2
by: hplloyd | last post by:
I am fairly new to VB.NET programming but have built many database applications in Access SQL Server etc. I need to find a good book or other reference material that will help me take my OO...
6
by: Randy Yates | last post by:
Hi Folks, I'm looking for something that is completely independent of the MSVC++ Dev Studio environment, something that will compile and run under win32 using the mingw distribution. A class...
3
by: Alan | last post by:
I am coming from other programming tools field, and new to VB .NET. Just wondering what is the common approaching in database programming in VB .NET? 1) Are you guru always using the data aware...
3
by: jaYPee | last post by:
i am searching a lot of resources in the net that discusses about database programming. i'm still searching on it and would like to received any links that discusses about database programming in...
1
by: Dave | last post by:
Hi, I work on a small team that currently uses an access 97 database for managing peoples time. The database front end is heavily implemented in VBA and is secured with user level security,...
8
by: Maxi | last post by:
Hello, i'm sorry my bad english :( I have CR9 Webservice, how to change databadse name and User_name into Webservice method? (not Viewer Control) Tks!! -- --------------------------
2
by: webcm123 | last post by:
People say that structural programming isn't good for database connection. I code fast-running structural oriented CMS and I don't know what I should do. I use mysql connection using mysql_*. I...
4
by: triton96 | last post by:
I want to get in to programming but would like your input on a couple of things: I would like to write some basic applications that would for example create a payroll check or create a billing for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.