Solved

Opening a New Page to Display Results

Posted on 2013-01-21
5
285 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple function not working 7 43
Use "if not" in a condition 2 18
javascript form submition 2 21
PHP SMTP authentication 6 24
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

763 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