PHP Connection to ODBC code

Source: Internet
Author: User
Tags integer odbc access database

Also do not know how long it road can go, and then other skills more than a temporary gain and loss, with their own interests, can learn how much more how much ....

This is an example of using PHP to connect ODBC (copied), ODBC also need to set up, note to Xuan System DSN, colleagues say that the performance of ODBC is not very good!

?
/* This example is a demo of using PHP4 to Access database operations through ODBC * *
?>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
<style type= "Text/css" >
<!--
input {font-size:9pt;}
a:link {text-decoration:underline; font-size:9pt;color:000059}
a:visited {text-decoration:underline; font-size:9pt;color:000059}
a:active {text-decoration:none; font-size:9pt}
A:hover
body,table {font-size:9pt}
Tr,td
-->
</style>
<title> Registered Members List-Access database demo via ODBC </title>
</HEAD>
<body alink= "#FF0000" link= "#000099" vlink= "#CC6600" topmargin= "8" leftmargin= "0" bgcolor= "#FFFFFF" >
<br><br><center><font color=green size=3><b> Registered member list </b></font></ Center>
<br>
<table cellspacing=0 bordercolordark= #FFFFFF width= "#000000" bordercolorlight= border=1 "center" cellpadding= "2" >
<tr bgcolor= "#6b8ba8" style= "COLOR:FFFFFF" >
&LT;TD width= "5%" align= "center" valign= "Bottom" height= ">ID</td>"
&LT;TD width= "10%" align= "center" valign= "Bottom" > Name </td>
&LT;TD width= "5%" align= "center" valign= "bottom" > Sex </td>
&LT;TD width= "5%" align= "center" valign= "Bottom" > Age </td>
&LT;TD width= "20%" align= "center" valign= "Bottom" > Tel </td>
&LT;TD width= "20%" align= "center" valign= "bottom" > Email </td>
&LT;TD width= "20%" align= "center" valign= "Bottom" > Home address </td>
</tr>
?
Connecting to an ODBC database
$myconn =odbc_connect ("Phptest", "sa", "etc");
$STRSQL = "SELECT * from Reguser";
/* Execute Inquiry * *
$result =odbc_do ($myconn, $STRSQL);
Boolean odbc_fetch_row (integer result,integer row)
while (Odbc_fetch_row ($result))///Read data content by looping
{
?>
<tr>
&LT;TD align= "center" height= "><?echo odbc_result" ($result, 1)?></td>
&LT;TD align= "center" ><?echo Odbc_result ($result, 2)?></td>
&LT;TD align= "center" ><?echo Odbc_result ($result, 3)?></td>
&LT;TD align= "center" ><?echo Odbc_result ($result, 4)?></td>
&LT;TD align= "center" ><?echo Odbc_result ($result, 5)?></td>
&LT;TD align= "center" ><?echo Odbc_result ($result, 6)?></td>
&LT;TD align= "center" ><?echo Odbc_result ($result, 7)?></td>
</tr>
?
}
To close a connection to a database
Odbc_close ($myconn);
?>
</table>
</BODY>
</HTML>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.