www.pickatutorial.com Computer Tutorials
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons PHP with ODBC 2 Bookmark and Share
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
In this lesson we will be exploring different php odbc functions.

Retrieving Records
The odbc_fetch_row() function is used to return records from the result-set. This function returns true if it is able to return rows, otherwise it returns false.

The function takes two parameters:
the ODBC result identifier and
an optional row number:


Retrieving Fields from a Record
The odbc_result() function is used to read fields from a record. This function takes two parameters:
the ODBC result identifier and
a field number or name.

The following code line returns the value of the first field from the record set:

$compname=odbc_result($resultSet, 1);

The code line below returns the value of a field called "city":

$city=odbc_result($rs, "city");

Closing an ODBC Connection
The odbc_close() function is used to close an ODBC connection as follows:


A practical ODBC Example
The following example first creates an ODBC data connection, then retrieves data from the database using the earlier created ODBC data connection, and then displays the retrieved data in a table:
	if (!$conn){
	   exit("Connection to the database Failed: " . $conn);
	$sql="SELECT * FROM customers";
	$resultSet=odbc_exec($conn, $sql);
	if (!$resultSet){
           echo "<table><tr>";
	   echo "<th>Company</th>";
	   echo "<th>Contact</th></tr>";
	   while (odbc_fetch_row($resultSet))
		echo "<tr><td>$company</td>";
		echo "<td>$contact</td></tr>";
	   echo "</table>";

Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.