Prev | Current Page 340 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

1 302 Found');
header('Location: ' .
Link::ToSearchResults($this->mSearchString, $this->mAllWords));
// Clear the output buffer and stop execution
flush();
ob_flush();
ob_end_clean();
exit();
}
CHAPTER 8 ?–  SEARCHING THE CATALOG 238
elseif (isset ($_GET['SearchResults']))
{
$this->mSearchString = trim(str_replace('-', ' ', $_GET['SearchString']));
$this->mAllWords = isset ($_GET['AllWords']) ? $_GET['AllWords'] : 'off';
}
if (isset ($_GET['ProductId']) &&
isset ($_SESSION['link_to_continue_shopping']))
{
$continue_shopping =
Link::QueryStringToArray($_SESSION['link_to_continue_shopping']);
if (isset ($continue_shopping['SearchResults']))
{
$this->mSearchString =
trim(str_replace('-', ' ', $continue_shopping['SearchString']));
$this->mAllWords = $continue_shopping['AllWords'];
}
}
}
}
?>
3. Open presentation/link.php, and add the following two methods to the Link class:
// Create link to the search page
public static function ToSearch()
{
return self::Build('index.php?Search');
}
// Create link to a search results page
public static function ToSearchResults($searchString, $allWords,
$page = 1)
{
$link = 'search-results/find';
if (empty($searchString))
$link .= '/';
else
$link .= '-' . self::CleanUrlText($searchString) . '/';
$link .= 'all-words-' . $allWords . '/';
if ($page > 1)
$link .= 'page-' . $page .


Pages:
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352