Ok,
I am currently grabbing some data from my database using an ODBC connection linking to Access. And basically, my results are being shown ok, but every single record in my database is being repeated 4 times, so my search results page looks somehting like this:
Record 1. [description of the record]
Record 1. [description of the record]
Record 1. [description of the record]
Record 1. [description of the record]
Record 2. [description of the record]
Record 2. [description of the record]
Record 2. [description of the record]
Record 2. [description of the record]
...etc where the results are obviously, only supposed to be:
Record 1. [description of the record]
Record 2. [description of the record]
...etc
This is my code on the page displaying these results:
<?
include 'odbc.php';
$query = odbc_exec($odbc, "SELECT Plus.Code, Plus.Desc, Plus.Price, Groups.GroupDesc FROM Plus, Groups WHERE Plus.Group=Groups.GroupCode AND Groups.GroupDesc='GLOSS'") or die (odbc_errormsg());
while($row = odbc_fetch_array($query)){
for($i=0; $i<count($row); $i++) {
//then there is a table showing this data to the user.
}
}
?>
If it helps, this is my code for my page named odbc.php. which connects to the data source:
<?
$odbc = odbc_connect (***, '', '') or die( "Could Not Connect to ODBC Database!");
if (function_exists(odbc_fetch_array))
return;
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;
}
?>
Any help would be appreciated regarding this matter. Thanks in advance.