Hi,
The code is fairly straightforward, so this change is fairly easy.
To change what happens when there are no results found edit this
portion of the code:
// If no listings, then we are done
$totalListings = sizeof( $listings );
if( 0 == $totalListings ) {
echo '</body></html>';
exit;
}
This code essentially checks the number of listings, and if it is zero
then it sends closing HTML code, and exits the script.
Change the "echo '</body></html>';" line to something else, for example:
$totalListings = sizeof( $listings );
if( 0 == $totalListings ) {
echo 'Sorry, no resutlts were found. Please try another search term.';
exit;
}
It shouldn't be necessary to including the closing HTML code in there,
as it looks from the code as if this script is included in another
page, so the HTML document should be closed in that.
Also, the following line, on Line 98 or so, is unnecessary and
actually appears in the output of the script.
#####The code above gathers the data and the code below displays it ########
To fix this you can do one of three things...
1) Delete it (it's just a comment, it doesn't affect the program's operation)
2) Remove the '?>' above and '<?php' below it. It will be evaluated as
PHP and ignored (as it should be).
3) Put "<!-- " in front and " -->" behind it to make it an HTML
comment. It will no longer be displayed.
Let me know if you have any problems with this.
Regards,
Sycophant |
Clarification of Answer by
sycophant-ga
on
13 Aug 2006 15:38 PDT
Hi,
In my copy of the code, copy and pasted from here, the 'Foreach' line
seems to be on line 67, and reads as follows:
foreach ($tags['LISTING'] as $key=>$val) {
To fix this the easiest thing might be to add a conditional to that
portion of code, so it reads like this:
if (is_array($tags['LISTING'])) {
foreach ($tags['LISTING'] as $key=>$val) {
if( 'open' == $values[$val]['type'] ) {
$listings[$listingIndex] = $values[$val]['attributes'];
$listingIndex++;
}
}
}
To make the code appear in place of the search output, do the following:
// If no listings, then we are done
$totalListings = sizeof( $listings );
if( 0 == $totalListings ) {
?>
<HTML CODE>
<?php
exit;
}
Where it says <HTML CODE> you can include any HTML code at all, so you
can create a more stylised error result to match the style of the
page.
Regards,
Sycophant
|