Do some stuff here to handle a neg result

"; exit; } $resultIds = getIdsForKeyword($keyword); $outputTest = "\r\n\r\n

Results for keyword '$keyword'...

\r\n"; if (isset($_GET['source']) && is_numeric($_GET['source'])) { $source = $_GET['source']; $outputTest .= "\r\n
Back to Issue $source
"; } foreach ($resultIds as $id) { $result = getArticleSummary($id); $articleLink = getArticleLink($result); // THE GET ARTICLE LINK FUNCTION RETURNS FALSE IF THE ARTICLE CAN'T BE FOUND. // IF NO FILE EXISTS WE SHOULD MOVE ONTO THE NEXT RESULT... if (!$articleLink) continue; $outputTest .= "\r\n
\r\n"; $outputTest .= "{$result['headline']}
"; $outputTest .= substr(strip_tags($result['story']), 0, 400).'.....
'; $issueLink = "../archive/news{$result['issue']}.htm"; $outputTest .= "
Issue {$result['issue']} - ".makeHumanDate($result['date'], 'words')." - Story Number {$result['story_number']}

"; $outputTest .= "
"; } // Find feature articles that match the keyword... $featureIds = getFeatureIdsForKeyword($keyword); $feature_output = array(); $num_features = count($featureIds); if ($num_features == 0) { $feature_message = "There aren't any features that match your keyword of '$keyword'"; } elseif ($num_features == 1) { $feature_message = "There is 1 feature that matched your keyword of '$keyword'"; } else { $feature_message = "There are $num_features features that match your keyword of '$keyword'"; } $feature_output[] = "
$feature_message
"; foreach ($featureIds as $id) { $result = getFeatureSummary($id); $feature_output[] = $result; } $feature_output = implode("\r\n", $feature_output); $templateFile = 'template.tpl'; $template = file_get_contents($templateFile); $template = str_replace('
', '
'."\r\n\r\n".$feature_output."\r\n\r\n", $template); $template = str_replace('
', '
'."\r\n\r\n".$outputTest."\r\n\r\n", $template); echo $template; exit; function getArticleLink($articleData) { if (!is_array($articleData)) return false; // TEST WHETHER THE PHP VERSION EXISTS... $articleLink = "../archive/news{$articleData['issue']}{$articleData['story_number']}.php"; if (file_exists($articleLink)) return $articleLink; // ELSE, TEST IF HTML VERSION EXISTS... $articleLink = "../archive/news{$articleData['issue']}{$articleData['story_number']}.htm"; if (file_exists($articleLink)) return $articleLink; // ELSE, TEST IF THE HTML VERSION OF THE WHOLE ISSUE EXISTS.. $articleLink = "../archive/news{$articleData['issue']}.htm"; if (file_exists($articleLink)) return $articleLink; return false; } function getFeatureSummary($id) { // Test inputs... if (!is_numeric($id) || $id == 0) return false; $conn = mysqlConnect(); $sql = " SELECT title, blurb, date, graphic_xsmall FROM features WHERE id = $id "; $rs = mysqlQuery($sql, $conn); $feature = mysqlGetRow($rs); $date = makeHumanDate($feature['date'], 'words'); $output = array(); $output[] = "
"; $output[] = ""; $output[] = ""; $output[] = "
".$feature['blurb']."
"; $output[] = "
$date
"; $output[] = '
'; mysql_close($conn); return implode("\r\n", $output); }