Query returning all restults in DB not just the one I want ?
Posted: Mon Jan 26, 2009 4:00 pm
First I must admit I am using code written by the guy who had this job before me so I didn't write it. That said, when you run this code against his database it returns only one record (based on the ID variable passed from the previous page) but when I run the code against my database it returns all the records. Below is the code, can anyone tell me why this is returning everything rather than a specific item? Thanks
Code: Select all
<html>
<head>
<title>Adult weekly schedules</title>
<link rel="stylesheet" href="site.css" type="text/css"/>
</head>
<body>
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/FX.php" );
include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/server_data.php" );
include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/Developer/FMErrors.php" );
$query = new FX ($serverIP, $webCompanionport, $DataType);
$query->SetDBUserPass ($dbUser, $dbPassword);
$query->SetDBData('Weekly.fp7', 'Weekly');
$query->AddDBParam ('KeyID', $_GET['ID']);
$query->FMSkipRecords($skipSize);
$result = $query->FMFind();
$currentKey = key($result['data']);
$today= date("Ymd",mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")));
$currenttime = date("h:i:s A");
/* print_r($result); */
if ($result['foundCount'] > 0) {
foreach ($result['data'] as $key => $value) {
$date = strtotime($value['Date'][0]); // Converts FM date field to UNIX date
$dateDisplay = date("l, F jS", $date);
/* print_r($value['KeyID'][0]); */
echo "<p><strong>Adult weekly schedules</strong> for the week of: <strong>" . $dateDisplay . "</strong><br />\n";
echo "This schedule is up-to-date as of: " . $currenttime . "</p>\n";
echo "<table width=640 cellpadding=1 cellspacing=0 border=0 bgcolor=#ffffff>\n";
echo "<tr>\n";
echo "<td width=75 bgcolor=#A5BFAA>" . $value[Sun01][0] . "</td>\n";
echo "</tr>\n";
}
}
?>
</body>
</html>