• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

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

0
DS928
Asked:
DS928
  • 3
1 Solution
 
Luis PérezSoftware Architect in .NetCommented:
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.
0
 
Mark BradyCommented:
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.
0
 
DS928Author Commented:
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

0
 
DS928Author Commented:
OK, have been playing around with it all morning.  It seems from what I can find is that the php is inter-mixed with the body of the code for this to display.  Every example reflects this.  So after playing around with it, I added more page formating to the code and walla I have what I want.  Thank you both for your help.

<?php
$username="";
$password="";
$database="MyDB";
$host="";

mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM tblCuisines";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/Steelers/results.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
	background-image: url(MHBackground.jpg);
	background-repeat: repeat;
}
</style>
<title>Politics</title>
</head>
<body>
<div class="container">
  <div class="header">
    <img src="../MHLogoTop.jpg" width="960" height="160" alt="Logo" />
      <table width="960" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td ><img src="../WhiteSearch.jpg" name="WhiteSearch" width="160" height="30" id="WhiteSearch" /></td>
          <td ><img src="../GreyOrder.jpg" name="GreyOrder" width="160" height="30" id="GreyOrder" /></td>
          <td ><img src="../GreyAbc.jpg" name="GreyABC" width="160" height="30" id="GreyABC" /></td>
          <td ><img src="../GreyMenus.jpg" name="GreyMenus" width="160" height="30" id="GreyMenus" /></td>
          <td ><img src="../GreyNews.jpg" name="GreyNews" width="160" height="30" id="GreyNews"  /></td>
          <td ><img src="../GreyReviews.jpg" name="GreyReviews" width="160" height="30" id="GreyReviews" /></td>
        </tr>
      </table>
    </div>
  <!--</div>-->


<div class="sidebar1">
    
    <p><strong>FILTER RESULTS</strong></p>
    <form id="form1" name="form1" method="post" action="">
      <p>
        <input type="checkbox" name="1" id="1" />
        <label for="1">Meal Periods</label>
      </p>
      <p>
        <input type="checkbox" name="2" id="2" />
        <label for="2">Price Points</label>
      </p>
      <p>
        <input type="checkbox" name="3" id="3" />
        <label for="3">Ratings</label>
      </p>
      <p>
        <input type="checkbox" name="4" id="4" />
        <label for="4">Hours</label>
      </p>
      <p>
        <input type="checkbox" name="5" id="5" />
        <label for="5">Theme</label>
      </p>
      <p>
        <input type="checkbox" name="6" id="6" />
        <label for="6">Full Bar</label>
      </p>
      <p>
        <input type="checkbox" name="7" id="7" />
        <label for="7">Handicap Access</label>
      </p>
      <p>
        <input type="checkbox" name="8" id="8" />
        <label for="8">Credit Cards</label>
      </p>
      <p>
        <input type="checkbox" name="9" id="9" />
        <label for="9">Delivery</label>
      </p>
      <p>
        <input type="checkbox" name="10" id="10" />
        <label for="10">Catering</label>
      </p>
      <p>
        <input type="checkbox" name="11" id="11" />
        <label for="11">Business Lunch</label>
      </p>
      <p>
        <input type="checkbox" name="12" id="12" />
        <label for="12">Kid Friendly</label>
      </p>
      <p>
        <input type="checkbox" name="13" id="13" />
        <label for="13">Reservations</label>
      </p>
    </form>
    <p>&nbsp;</p>
    <p>This is a good place for a restaurant to advertise! Everyone looks here for suggestions. Call us today!</p>
  <!--End Sidebar1 --></div>
<!--////////////////////////////////////////////////////////////////////////////////////////////-->

<div class="content">
<div>
<h1 align="left">RESULTS</h1>
<table border="0" cellspacing="2" cellpadding="2" align="left">
<tr>
<td><font face="Arial, Helvetica, sans-serif">ID</font></td>
<td><font face="Arial, Helvetica, sans-serif">NAME</font></td>
<td><font face="Arial, Helvetica, sans-serif">TYPE</font></td>
</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"CuisineID");
$f2=mysql_result($result,$i,"CuisineName");
$f3=mysql_result($result,$i,"CuisineType");
?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
</tr>

<?php
$i++;
}
?>
</table>
</div>
</div>
<!--</body>-->
<!--End Content</div>-->
<div class="footer">
<h2 align="center">&nbsp;</h2>
<!-- End Footer --></div>
<!--End Container--></div>
</body>
</html>

Open in new window

0
 
DS928Author Commented:
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now