note 117327 added to function.odbc-connect

From: Date: Thu, 21 May 2015 22:47:18 +0000
Subject: note 117327 added to function.odbc-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-202637@lists.php.net to get a copy of this message
<?php //create an instance of the ADO connection object $conn = new COM ("ADODB.Connection") or die("Cannot start ADO"); //define connection string, specify database driver $connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source= c:\inetpub\wwwroot\db\examples.mdb"; $conn->open($connStr); //Open the connection to the database //declare the SQL statement that will query the database $query = "SELECT * FROM cars"; //execute the SQL statement and return records $rs = $conn->execute($query); $num_columns = $rs->Fields->Count(); echo $num_columns . "<br />"; for ($i=0; $i < $num_columns; $i++) { $fld[$i] = $rs->Fields($i); } echo "<table>"; while (!$rs->EOF) //carry on looping through while there are records { echo "<tr>"; for ($i=0; $i < $num_columns; $i++) { echo "<td>" . $fld[$i]->value . "</td>"; } echo "</tr>"; $rs->MoveNext(); //move on to the next record } echo "</table>"; //close the connection and recordset objects freeing up resources $rs->Close(); $conn->Close(); $rs = null; $conn = null; ?> ---- Server IP: 72.52.91.14 Probable Submitter: 2602:306:8098:d240:1014:2cd5:fa37:31ec ---- Manual Page -- http://php.net/manual/en/function.odbc-connect.php Edit -- https://master.php.net/note/edit/117327 Del: integrated -- https://master.php.net/note/delete/117327/integrated Del: useless -- https://master.php.net/note/delete/117327/useless Del: bad code -- https://master.php.net/note/delete/117327/bad+code Del: spam -- https://master.php.net/note/delete/117327/spam Del: non-english -- https://master.php.net/note/delete/117327/non-english Del: in docs -- https://master.php.net/note/delete/117327/in+docs Del: other reasons-- https://master.php.net/note/delete/117327 Reject -- https://master.php.net/note/reject/117327 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202637) next »