PHP連接ODBC的代碼
也不知道自已的IT路能走多長,以後也別技較一時的得失了,憑自已興趣,能學多少就學多少了....
(KOp5Ch/U(C0 IXPUB技术博客Hm5@2]0U~這是個用PHP連接ODBC的例子(抄來的),ODBC還要設定一下,注意要選報系統DSN,同事說用ODBC性能不太好!管它呢....
!Dpm\^,D,N#B8B0 IXPUB技术博客Vs(E;LA]_ `8C-g<?
1|
l
jVe.~0|`0 /*本例是用PHP4通过ODBC访问数据库操作的演示*/
p2s&Sxw^UlC0?>
R{4n@(\-}K0<HTML>
+Q~'TZq'q@S0<HEAD>
5xYw;k+Q0<META. NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
._e8Y,F$G7BuZF"F0<style. type="text/css">
*kdG%D9l)J{E.s0<!--
R[c2NhcSF5R2b0input { font-size:9pt;}
.Z$M9z9N{0A:link {text-decoration: underline; font-size:9pt;color:000059}IXPUB技术博客Imh5s%MYt"t tV
A:visited {text-decoration: underline; font-size:9pt;color:000059}IXPUB技术博客;z0LMVa/[3sz8d [1T
A:active {text-decoration: none; font-size:9pt}IXPUB技术博客Ea)S*J4y
A:hover
$^#i+A?|(b-T0body,table {font-size: 9pt}IXPUB技术博客`pE2@,eIf
tr,tdIXPUB技术博客_k`4vA&sB
-->IXPUB技术博客"i}2k)T-[g
</style>IXPUB技术博客^
fb&d)iZ2PM:L~H
<title>注册会员列表 - 通过ODBC访问数据库演示</title>IXPUB技术博客eT"p7z&VsC2Y D*E
</HEAD>
)t?`uh']+E'\0<body alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF">IXPUB技术博客g
~XKon
<br><br><center><font color=green size=3><b>注 册 会 员 列 表</b></font></center>
&kF
fJ*^'gQ0<br>
]V"vu^n
j4Z|0<table cellspacing=0 bordercolordark=#FFFFFF width="95%" bordercolorlight=#000000 border=1 align="center" cellpadding="2">IXPUB技术博客5Y Ds2IPdb'xog
<tr bgcolor="#6b8ba8" style="color:FFFFFF">
-{?ZaX!Y_y1b3\0 <td width="5%" align="center" valign="bottom" height="19">ID</td>
zl4N
r:a1J(l4}0 <td width="10%" align="center" valign="bottom">姓名</td>
I
?*Y:t4mt8|az0 <td width="5%" align="center" valign="bottom">性别</td>IXPUB技术博客 Kk:\D;~i
<td width="5%" align="center" valign="bottom">年龄</td>
g%P_u5SL+k i0 <td width="20%" align="center" valign="bottom">联系电话</td>
C|4u*x/t!g0 <td width="20%" align="center" valign="bottom">电子邮件</td>
t1UMi5e0 <td width="20%" align="center" valign="bottom">家庭住址</td>IXPUB技术博客R+z8t(BdpT9DY$q
</tr>
(B zED6X:A;@\0<?
w \g@Zp6r0 //连接到ODBC数据库IXPUB技术博客9O:h3I0W ufR+Vs
$myconn=odbc_connect("phptest","sa","etc");IXPUB技术博客H!F;b(GKe*R*e.x-y
$strSql="select * from reguser";IXPUB技术博客iE]$VxX
/*执行查询*/IXPUB技术博客8_%wvcO#I,lC S5v0x
$result=odbc_do($myconn,$strSql);IXPUB技术博客/}B1aXs8j#G,v'L
//Boolean odbc_fetch_row(integer result,integer row)IXPUB技术博客7Q]Abq-k*a5h9U
while(odbc_fetch_row($result))//通过循环读取数据内容IXPUB技术博客U
OX1Q u
{
!j$z2C)R,C9e.qi0?>
a8X ]Sk7WNMC0 <tr>
F*\V)Xw q6h'{0 <td align="center" height="19"><?echo odbc_result($result,1)?></td>IXPUB技术博客G7S(Y4ZkTEq2VO"q
<td align="center"><?echo odbc_result($result,2)?></td>
6@3rh2C Oh0 <td align="center"><?echo odbc_result($result,3)?></td>IXPUB技术博客@8i$_Vaw6m%Gg{
<td align="center"><?echo odbc_result($result,4)?></td>IXPUB技术博客1c.EEi
V$q$XrW
<td align="center"><?echo odbc_result($result,5)?></td>
$?H6f6tV`0 <td align="center"><?echo odbc_result($result,6)?></td>IXPUB技术博客9Df9Jd-IGvm&g
<td align="center"><?echo odbc_result($result,7)?></td>IXPUB技术博客]df\9?&t9E
</tr>IXPUB技术博客.K3B:e6r6k0D:M}P7{
<?
3`~4Y1|/v$S:{0 }IXPUB技术博客sybB+pt/l1?L
//关闭对数据库的连接
o)z&x.L