note 30396 added to ref.odbc
| From: | (lalista.fly.to) | Date: | Sun, 16 Mar 2003 22:43:41 +0000 |
| Subject: | note 30396 added to ref.odbc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45399@lists.php.net to get a copy of this message | ||
FOR ASP-COMERS
--------------
You can use the ADODB interface instead. It's the same code than ASP, but it's written in
PHP:
<HTML>
<HEAD>
<TITLE>ADODB Test in PHP</TITLE>
</HEAD>
<BODY>
<?php
$Connection = new COM("ADODB.Connection");
$RecordSet = new COM("ADODB.RecordSet");
$Connection -> Open("Provider=SQLOLEDB; DBQ=MyServer; UID=MyUser;
PWD=MyPassword");
$RecordSet = $Connection -> Execute("SELECT * FROM MyTable");
while(!$RecordSet -> EOF)
{
echo "\"" . $RecordSet -> Fields(0) . "\"";
echo "costs $" . $RecordSet -> Fields(1) . "< BR>";
$RecordSet -> MoveNext() #Don't forget this
}
$Connection -> Close();
$Connection -> Release();
$RecordSet -> Release();
$Connection = null;
$RecordSet = null;
?>
</BODY>
</HTML>
Supposing this is the table:
Article(0) Price(1)
Wine 19.95
CD-RW 1.49
CD-R 0.49
Pen 0.45
This will be the output:
<HTML>
<HEAD>
<TITLE>ADODB Test in PHP</TITLE>
</HEAD>
<BODY>
"Wine" costs $19.95< BR>
"CD-RW" costs $1.49< BR>
"CD-R" costs $0.49< BR>
"Pen" costs $0.45< BR>
</BODY>
</HTML>
--
http://www.php.net/manual/en/ref.odbc.php
http://master.php.net/manage/user-notes.php?action=edit+30396
http://master.php.net/manage/user-notes.php?action=delete+30396
http://master.php.net/manage/user-notes.php?action=reject+30396