这有可能吗?
我确实找到了
$user='';
$password='';
$mdbFilename="myDatabase.accdb";
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $user, $password);
$sql="SELECT * FROM [tblNameHere]";
$rs=odbc_exec($connection,$sql);
$myResults=odbc_result($rs,"fieldNameHere");
echo 'First entry: ' . $myResults;
//Move to next record here
$myResults=odbc_result($rs,"fieldNameHere");
echo 'Second entry: ' . $myResults;
odbc_close($connection);这只会将第一条记录放两次,我可以返回第一条记录的任何字段值,但如果它存在,则无法将其更改为下一条记录。
发布于 2014-08-08 22:22:25
您需要循环遍历记录,使用odbc_fetch_row
$sql="SELECT * FROM [tblNameHere]";
$rs=odbc_exec($connection,$sql);
while (odbc_fetch_row($rs)) {
$myResults =odbc_result($rs,"fieldNameHere");
echo "Entry: " . $myResults;
}
odbc_close($connection);odbc (PHP4,PHP5) odbc_fetch_row -获取一行 描述
bool odbc_fetch_row ( resource $result_id [, int $row_number ] )生成由odbc_do()或odbc_exec()返回的数据行。调用odbc_fetch_row()之后,可以使用odbc_result()访问该行的字段。
“手动”
$rs=odbc_exec($connection,$sql);
$myResults=odbc_result($rs,"fieldNameHere");
echo 'First entry: ' . $myResults;
//Move to next record here
odbc_fetch_row($rs); //<----MoveNext() manually
$myResults=odbc_result($rs,"fieldNameHere");
echo 'Second entry: ' . $myResults;https://stackoverflow.com/questions/25212277
复制相似问题