Solved

Opening a New Page to Display Results

Posted on 2013-01-21
5
254 Views
Last Modified: 2013-01-27
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
Comment
Question by:DS928
  • 3
5 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 38804384
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
 
LVL 20

Expert Comment

by:Mark Brady
ID: 38805261
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
 

Author Comment

by:DS928
ID: 38805701
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
 

Accepted Solution

by:
DS928 earned 0 total points
ID: 38806441
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
 

Author Closing Comment

by:DS928
ID: 38823797
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
spacing 5 32
Safari SVG Image Problem 1 21
Creating Image Thumbnails Using PHP 3 16
Jquery autocomplete 10 31
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now