Drewser33 Posted March 11, 2008 Share Posted March 11, 2008 All, I am only familiar with mysql and cannot figure out how to change even a simple query to run from an Access Db instead of a mysql. Could anyone tell me how to change the commands in this query to work assuming all table names and columns are the same? $query = "SELECT ID,FirstName,LastName,TransmiterID, TxOrPanic FROM MemberData ORDER BY FirstName"; $result = mysql_query($query) or die (mysql_error()); ?> <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>"> <table> <tr> <td> Select up to seven residents to compare call button alarms and average response time: </td> </tr> <tr> <td> <select name=residenta> <option value = "0">None</option> <?php while($row = mysql_fetch_array($result)) { if($row['TransmiterID'] <> -1 AND $row['TxOrPanic'] == 0) { $id = $row['ID']; $querya = "SELECT ObjectID FROM EventLogger WHERE ObjectID = '$id' AND EventCode = 'OID'"; $resulta = mysql_query($querya) or die (mysql_error()); $selectcheck = mysql_num_rows($resulta); if($selectcheck > 0) { ?> <option value="<?php echo $row['ID']; ?>"><?php echo $row['FirstName']. ' '. $row['LastName']; ?></option> <?php } } } ?> </select> </td> </tr> Thanks Drew Link to comment https://forums.phpfreaks.com/topic/95606-struggling-with-odbcaccess/ Share on other sites More sharing options...
Drewser33 Posted March 11, 2008 Author Share Posted March 11, 2008 $query = "SELECT ID,FirstName,LastName,TransmiterID, TxOrPanic FROM MemberData ORDER BY FirstName"; $result = odbc_exec($odbc,$query) or die (odbc_error()); if(!isset($_GET['run'])) { ?> <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>"> <table> <tr> <td> Select up to seven residents to compare call button alarms and average response time: </td> </tr> <tr> <td> <select name=residenta> <option value = "0">None</option> <?php while($row = odbc_fetch_array($result)) { if($row['TransmiterID'] <> -1 AND $row['TxOrPanic'] == 0) { $id = $row['ID']; $querya = "SELECT COUNT(ObjectID) FROM EventLogger WHERE ObjectID = $id AND EventCode = 'OID'"; $resulta = odbc_exec($odbc,$querya) or die (odbc_error()); $selectcheck = odbc_result($resulta,1); if($selectcheck > 0) { ?> <option value="<?php echo $row['ID']; ?>"><?php echo $row['FirstName']. ' '. $row['LastName']; ?></option> <?php } } } ?> </select> </td> </tr> using this function with the connection - if(!function_exists('odbc_fetch_array')) { function odbc_fetch_array($result, $rownumber=-1) { if (PHP_VERSION > '4.1') { if ($rownumber < 0) { odbc_fetch_into($result, $rs); } else { odbc_fetch_into($result, $rs, $rownumber); } } else { odbc_fetch_into($result, $rownumber, $rs); } $rs_assoc = Array(); foreach ($rs as $key => $value) { $rs_assoc[odbc_field_name($result, $key+1)] = $value; } return $rs_assoc; } } Link to comment https://forums.phpfreaks.com/topic/95606-struggling-with-odbcaccess/#findComment-489518 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.