Link to home
Start Free TrialLog in
Avatar of DS928
DS928Flag for United States of America

asked on

Opening a New Page to Display Results

I have a search page.  When the results come up I need them to be directed to this page  tabresukts.html    to the class: content part.  Right now my code is not doing that.  How can I fix this?  Here is my code.

if(!$result->countRows()){
echo '<div align="center">

<body>
<div align="center">
<div align="center"><img src="../MHLogoTop.jpg" alt="" width="960" height="160" />

<div class="maincontainer">

<h2>No restaurants were found. Go
back and try a new search.</h2></div>'." ";
 
}
 
else{
 
// display search results

 
echo '<div align="center">
<body>
<div align="center">
<div align="center"><img src="../MHLogoTop.jpg" alt="" width="960" height="160" />

<div class="maincontainer">

<h2>MenuHead found '.$result->countRows().' restaurants.</h2>'." ";
 
while($row=$result->fetchRow()){
 
echo '<div class="rowcontainer"><p><strong>Restaurant:
</strong>'.$row['RestName'].'<p><p><strong>Cuisine:
</strong>'.$row['CuisineName'].'</p></div>'." "; 


}
 
}
 
echo '</div>';
 
}
 
catch(Exception $e){
 
echo $e->getMessage();
 
exit();

Open in new window

Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

Maybe the problem is that you're enclosing the body tag inside a div tag. Body must the the opening tag for all other visible tags of the document. Try setting the body tag in first place and containing all other else.

Hope that helps.
I suggest you search for some good tutorials on html and php. In your code you are mixing php and html together which won't work.

Uoi have no php opening/closing tags so the php will never be parsed. You are using a class method but I don't see any class declaration.

As for redirecting you can do that in php with a header call

header("location: some_page.php");

as long as nothing has been output top the browser already. Other wise you can do it in javascript. I would work on tidying up your code first.
Avatar of DS928

ASKER

Here is the link and the entire page code.  This works, but I want to go to a specific page  results.html in the class content div.  Click on search to see the current code run, click New to see the desired page.
http://www.menuhead.net/Steelers/sections_demo.php

<link href="default.css" rel="stylesheet" type="text/css" media="screen" />

<?php
 
// include MySQL-processing classes
require_once 'mysql.php'; 
try{
$Fid=$_POST['Fid'];
$db=new MySQL(array
('host'=>'','user'=>'','password'=>'',
'database'=>'MyDB'));

$searchterm=$db->escapeString($_GET['Pig']);

$result = $db->query("SELECT tblLocations.CuisineID, tblLocations.RestID, tblRestaurants.RestName, tblLocations.StreetNumber, tblLocations.Street
FROM tblRestaurants INNER JOIN tblLocations ON tblRestaurants.RestID = tblLocations.RestID
WHERE tblLocations.CuisineID = '3'
ORDER BY tblRestaurants.RestName ASC");

 
if(!$result->countRows()){
echo '<div align="center">

<body>
<div align="center">
<div align="center"><img src="../MHLogoTop.jpg" alt="" width="960" height="160" />

<div class="maincontainer">

<h2>No restaurants were found. Go
back and try a new search.</h2></div>'." ";
 
}
 
else{
 
// display search results

 
echo '<div align="center">
<body>
<div align="center">
<div align="center"><img src="../MHLogoTop.jpg" alt="" width="960" height="160" />

<div class="maincontainer">

<h2>MenuHead found '.$result->countRows().' restaurants.</h2>'." ";
 
while($row=$result->fetchRow()){
//echo "<td><a href=\"tabresults.php?cd=$CuisineID\">$CuisineID</a></td>";
echo '<div class="rowcontainer"><p><strong>Restaurant:
</strong>'.$row['RestName'].'<p><p><strong>Street Number:
</strong>'.$row['StreetNumber'].'<p><strong>Street Name:
</strong>'.$row['Street'].'</p></div>'." "; 


}
 
}
 
echo '</div>';
 
}
 
catch(Exception $e){
 
echo $e->getMessage();
 
exit();
 
}
 
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DS928
DS928
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DS928

ASKER

This works perfectly.  It returns the results to a page that is formatted like the rest of the site.  Here is the link that helped alot.  Thank you everyone for your input.

http://www.siteground.com/tutorials/php-mysql/display_table_data.htm