Re: ODBC
| From: | Richard Lynch | Date: | Fri, 03 Aug 2001 21:32:35 +0000 |
| Subject: | Re: ODBC | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-61185@lists.php.net to get a copy of this message | ||
Create a DSN using the ODBC Control Panel. Name the db something useful
(I'll use "foo") and set up a username/password in that interface, and point
the source at your ms-access filename.mdb
Then, something not unlike:
<?php
$connection = odbc_connect("foo", "username", "password");
$query = "select id, name, whatever from yourtable order by name";
$records = odbc_exec($connection, $query) or die(odbc_error());
$recordcount = 0;
while ($row = odbc_fetch_row($records)){
$id = odbc_result($records, $recordcount, 0);
$name = odbc_result($records, $recordcount, 1);
$whatever = odbc_result($records, $recordcount, 2);
echo "$id: $name $whatever<BR>\n";
}
?>
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: Jtjohnston <jtjohnston@courrier.usherb.ca>
Newsgroups: php.general
To: <php-general@lists.php.net>
Sent: Thursday, August 02, 2001 10:41 PM
Subject: ODBC
> Can someone show me how to display the contents of a table in a MS
> Access file using ODBC on my Windows machine?
>
> Thanks,
> John
>