I am new to php still learning i have made a navigation with the drop down submenus its working when im inserting new item in navigation but the problem exist when i try to edit the same navigation i get the error in function everything seems fine need help.
![Edit Form][1]
Error:
<code>
Database Query Failed in get subject by idYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1
</code>
functions.php
<code>
// Get Subject By ID
function get_subject_by_id($subject_id){
global $connection;
$query = "SELECT * FROM subjects WHERE id = {$subject_id} LIMIT 1";
$result_set = mysqli_query($connection, $query);
if(!$result_set){
die("Database Query Failed in get subject by id" . mysqli_error($connection));
}
if($subject_data = mysqli_fetch_array($result_set)) {
return $subject_data;
} else {
return null;
}
}
</code>
edit_subject.php
<code>
<?php include('includes/connection.php'); ?>
<?php require_once('includes/functions.php'); ?>
<?php
if(isset($_POST['submit'])) {
$id = $_GET['subj'];
$menu_name = $_POST['menu_name'];
$position = $_POST['position'];
$visible = $_POST['visible'];
$content = $_POST['content'];
$query = "UPDATE subjects SET menu_name = '{$menu_name}', position = {$position}, visible = {$visible}, content = '{$content}' WHERE id = {$id}";
$result_update = mysqli_query($connection, $query);
if(mysqli_affected_rows($connection) == 1){
$message = "The Subject was successfully created.";
} else {
}
}
?>
<?php
if(isset($_GET['subj'])){
$sel_subject = get_subject_by_id($_GET['subj']);
$sel_page = NULL;
} elseif (isset($_GET['page'])) {
$sel_subject = NULL;
$sel_page = get_page_by_id($_GET['page']);
} else {
$sel_subject = NULL;
$sel_page = NULL;
}
?>
<?php include('includes/header.php'); ?>
<div class="sidebar">
<ul class="sideNav">
<?php
$query_sub = "SELECT * FROM subjects";
$subject_set = mysqli_query($connection, $query_sub);
if(!$subject_set){
die("Database Query Failed1");
}
while($subject = mysqli_fetch_array($subject_set)){
?>
<li><?php echo $subject["menu_name"]; ?>
<?php
$query_page = "SELECT * FROM pages WHERE subject_id = {$subject["id"]}";
$page_set = mysqli_query($connection, $query_page);
if(!$page_set){
die("Database Query Failed2");
} ?>
<ul>
<?php
while($page = mysqli_fetch_array($page_set))
{
?><li><?php echo $page["menu_name"]; ?></li><?php
} ?>
</ul>
</li>
<?php } ?>
</ul>
<br>
+ Add a new Subject
</div><!-- end of sidebar -->
<h2>Edit Subject: <?php echo $sel_subject['menu_name']; ?></h2>
<div class="main">
<br/> <br/>
<?php if(!empty($message)) { ?> <p><?php echo $message; ?></p> <?php } ?>
<form action="edit_subject.php?subj=<?php $sel_subject['id']; ?>" method="post">
<fieldset>
<legend>Edit Subject:</legend>
<p>Subject Name:
<input type="text" name="menu_name" value="<?php echo $sel_subject['menu_name']; ?>">
</p>
<p>Position:
<select name="position">
<?php
$query_opt = "SELECT * FROM subjects ORDER BY position ASC";
$subject_opt = mysqli_query($connection, $query_opt);
if(!$subject_opt){
die("Database Query Failed3");
}
$subject_count = mysqli_num_rows($subject_opt);
for($count=1; $count <= $subject_count+1; $count++){
echo "<option value=\"{$count}\"";
if($sel_subject['position'] == $count){
echo " selected";
}
echo ">{$count}</option>";
}
?>
</select>
</p>
<p>Visible:
<input type="radio" name="visible" value="0"<?php if($sel_subject['visible'] == 0){ echo " checked"; } ?>> No
<input type="radio" name="visible" value="1"<?php if($sel_subject['visible'] == 1){ echo " checked"; } ?>> Yes
</p>
<p>Content:<br/>
<textarea name="content" rows="20" cols="150"><?php echo $sel_subject['content']; ?></textarea>
</p>
<p>
<input type="submit" name="submit" value="Add Subject" class="button-submit">
</p>
</fieldset>
</form>
<br /><br />
</div><!-- end of main -->
<?php include('includes/footer.php'); ?>
</code>
Are you sure that $subject_id in function get_subject_by_id() is not empty ? Try the below code after $query = "SELECT * FROM subjects WHERE id = {$subject_id} LIMIT 1"; in functions.php (only for testing) and make sure that your query is correct.
echo $query;
die();
you've missed the single quotes in the query string.
$query = "SELECT * FROM subjects WHERE id = {$subject_id} LIMIT 1";
should be
$query = "SELECT * FROM subjects WHERE id = '{$subject_id}' LIMIT 1";
youve also done it here.
$query = "UPDATE subjects SET menu_name = '{$menu_name}', position = {$position}, visible = {$visible}, content = '{$content}' WHERE id = {$id}";
should be
$query = "UPDATE subjects SET menu_name = '{$menu_name}', position = '{$position}', visible = '{$visible}', content = '{$content}' WHERE id = '{$id}'";
a note you dont need to wrap in {} for simple variables. You only need them if calling complex variables such as {$array['test']} as expained in this answer
Related
I have an application that where users can post announcements and comment on posts. My problem is that whenever a comment is posted, It shows up on every announcement post. How can I post comments so that they show up on that specific post?
I have 2 database tables: "announcement: id, name, announcementTitle, announcement, image" and "comment: id, post_id, name, comment" with foreign key attached to comment.
Here is my home.php where the announcements and comments are echoed
<div class="container">
<div class="mx-auto">
<?php
if (isset($_SESSION['username'])) {
echo'
<h1 style="text-decoration:underline">Post an announcement</h1>
<form method="post" action="announcement.php" enctype="multipart/form-data">
<input type="text" name="announcementTitle" placeholder="Enter Subject"><br>
<textarea name="announcementBox" rows="5" cols="40" placeholder="Enter Announcement"></textarea><br>
<input type="file" name="image" accept="image/jpeg">
<button name="announcement">Submit</button>
</form>';
}
$query = "SELECT * FROM announcement ORDER BY id DESC";
$result = mysqli_query($con,$query);
while ($row = mysqli_fetch_array($result)) {
echo '<div class="row" style="color:black;background-color:white;border-radius:5px;padding:10px;margin-top:10px;margin-bottom:70px">';
echo '<div class="column" style="width:100%;border:5px">';
if (isset($_SESSION['username'])) {
echo '<form method="post" action="announcement.php">';
echo "Posted by " .$row["name"]. " click X to delete:";
echo '<input type="hidden" name="postID" value="'.$row['id'].'">';
echo '<button name="delete" style="float:right">X</button>';
echo '</form>';
}
echo $row['announcementTitle'].'<br>';
echo $row['announcement'].'<br>';
echo '<img width="20%" src="data:image;base64,'.$row['image'].'"alt="Image" style="padding-top:10px">';
echo'
<form method="post" action="comment.php">
<textarea name="commentbox" rows="2" cols="50" placeholder="Leave a Comment"></textarea><br>
<button name="comment">Submit</button>
</form>';
echo "Comments:<p><p>";
echo " <p>";
$find_comment = "SELECT * FROM comment ORDER BY id DESC";
$res = mysqli_query($con,$find_comment);
while ($row = mysqli_fetch_array($res)) {
echo '<input type="hidden" name="postID" value="'.$row['post_id'].'">';
$comment_name = $row['name'];
$comment = $row['comment'];
echo "$comment_name: $comment<p>";
}
if(isset($_GET['error'])) {
echo "<p>100 Character Limit";
}
echo '</div></div>';
}
?>
</div>
</div>
Here is comment.php where comments are put in the database
<?php
session_start();
$con = mysqli_connect('localhost', 'root', 'Arv5n321');
mysqli_select_db($con, 'userregistration');
$namee = '';
$comment = '';
$comment_length = strlen($comment);
if($comment_length > 100) {
header("location: home.php?error=1");
}else {
$que = "SELECT * FROM announcement";
$res = mysqli_query($con,$que);
while ($row = mysqli_fetch_array($res)) {
$post_id = $row['id'];
}
$namee = $_SESSION['username'];
$comment = $_POST['commentbox'];
$query = "INSERT INTO comment(post_id,name,comment) VALUES('$post_id','$namee','$comment')";
$result = mysqli_query($con, $query);
if ($result) {
header("location:home.php?success=submitted");
} else {
header("location:home.php?error=couldnotsubmit");
}
}
?>
Here is announcement.php where announcements are put in the database
<?php
session_start();
//$con = mysqli_connect('freedb.tech', 'freedbtech_arvindra', 'Arv5n321', 'freedbtech_remote') or die(mysqli_error($con));
$con = mysqli_connect('localhost', 'root', 'Arv5n321', 'userregistration') or die(mysqli_error($con));
if (isset($_POST['announcement'])) {
$image = $_FILES['image']['tmp_name'];
$name = $_FILES['image']['name'];
$image = base64_encode(file_get_contents(addslashes($image)));
date_default_timezone_set("America/New_York");
$title = $_POST['announcementTitle']." (<b>".date("m/d/Y")." ".date("h:i:sa")."</b>)";
$paragraph = $_POST['announcementBox'];
if (empty($paragraph)||empty($title)) {
header('location:home.php?error=fillintheblanks');
}else{
$nam = $_SESSION['username'];
$query = "insert into announcement(name,announcementTitle,announcement,image) values('$nam','$title','$paragraph','$image')";
$result = mysqli_query($con, $query);
if ($result) {
header("location:home.php?success=submitted");
} else {
header("location:home.php?error=couldnotsubmit");
}
}
}else if (isset($_POST['delete'])){
$query = "delete from announcement where id='".$_POST['postID']."';";
$result = mysqli_query($con,$query);
if ($result) {
header('location:home.php?success=deleted');
} else {
header('location:home.php?error=couldnotdelete');
}
}
else {
header('location:home.php');
}
I am a little new to PHP so any help is good.
I want to display the mobile number in mobileNo label but when I enter the employee id for search this code displays no result.
I want to display data using the while loop in my html form
search.php
<?php
$output = NULL;
$mysqli = mysqli_connect("localhost","root","","db") or die ("Error in connection");
if(isset($_POST['search']))
{
$search = $mysqli->real_escape_string(isset($_POST['search']));
$resultSet = $mysqli->query("SELECT * FROM emp WHERE emp_id = '$search'");
if($resultSet->num_rows > 0)
{
while($rows = mysqli_fetch_row($resultSet))
{
$mobileNo = $rows['emp_mob_no'];
$output = "Mobile no: $mobileNo";
}
}
{
$output = "No result";
}
}
?>
display.php
<html>
<head>
</head>
<body>
<form action="search.php" method="post">
<ul>
<li>
<label for="employeeId">Employee Id</label>
<input type="text" name="employeeId" placeholder="Employee Id" />
<input type="submit" value="search" name="search"/>
</li>
<li>
<label for="mobileNo">Mobile No.</label>
<?php echo $output;?>
</li>
</form>
</body>
</html>
1st : you missed else That's why $output variable alwasy overwrite by No result .
2nd : $search = $mysqli->real_escape_string(isset($_POST['search'])); this line wrong isset will return boolean value your escaping for boolean value .
3rd : Try to use prepared statement to avoid sql injection .
PHP:
<?php
$output = NULL;
$mysqli = mysqli_connect("localhost","root","","db") or die ("Error in connection");
if(isset($_POST['search']))
{
$search=$_POST['search'];
$stmt = $conn->prepare("SELECT * FROM emp WHERE emp_id = ?");
$stmt->bind_param('i',$_POST['search']);
$stmt->execute();
$get_result = $stmt->get_result();
if($get_result->num_rows > 0)
{
while($rows = $get_result->fetch_assoc())
{
$mobileNo = $rows['emp_mob_no'];
$output = "Mobile no: $mobileNo";
}
}else //here else missed .
{
$output = "No result";
}
}
?>
<?php
$output = NULL;
$mysqli = mysqli_connect("localhost","root","","db") or die ("Error in connection");
if(isset($_POST['search']))
{
$search = $mysqli->real_escape_string($_POST['search']);
$resultSet = $mysqli->query("SELECT * FROM emp WHERE emp_id = '$search'");
if($resultSet->num_rows > 0)
{
while($rows = mysqli_fetch_assoc($resultSet))
{
$mobileNo = $rows['emp_mob_no'];
$output = "Mobile no: $mobileNo";
}
}
else
{
$output = "No result";
}
}
?>
I am in the process of creating a filter page that should return a table of results dependent upon the selection chose from a drop down list.
I have generated the code for this and no errors are found. However, no results show up despite them being present in the database.
Am I missing something?
Please let me know if any further information is required.
Any help would be greatly appreciated!
<?php
error_reporting(E_ALL);
ini_set('display_errors','1');
$search_output= "";
$link= mysqli_connect("localhost","root","");
mysqli_select_db($link,"assessment_centre_app");
if(isset($_POST['submit'])) {
$Name_FK = $_POST['Name_FK'];
$sqlCommand = mysqli_query($link, "SELECT *
FROM scores
WHERE 'Name_FK' = {'$Name_FK'}");
$query = mysql_query($sqlCommand) or die (mysql_error());
$count = mysqli_num_rows($query);
if($count > 1) {
$search_output .="$count results for $searchquery";
while($row = mysql_fetch_array($query)) {
$Candidate_Name_FK = $row["Candidate_Name_FK"];
$search_output .="Item ID: $Candidate_Name_FK <br />";
}
} else {
$search_output= "0 results found";
}
}
?>
<html>
<head>
</head>
<body>
<form action="http://localhost/scoresheet/scoresheetfilter.php" method="POST">
<label> Assessment Day Name </label>
<select name = "Name_FK">
<?php
$res=mysqli_query($link,"SELECT * FROM scores");
while($row=mysqli_fetch_array($res))
{
?>
<option>
<?php echo $row["Name_FK"]; ?>
</option>
<?php } ?>
</select>
<br>
<input name ="myBtn" id="submit" type="submit" >
<br>
</form>
<div>
<?php echo $search_output;
?>
</div>
</body>
</html>
Try this out if it still does not display anything the check the variable used to call this other one's
<?php
error_reporting(E_ALL);
ini_set('display_errors','1');
$search_output= "";
$link= new mysqli("localhost", "user_name", "password", "database");
if(isset($_POST['submit'])) {
$Name_FK = $_POST['Name_FK'];
$sqlCommand = "SELECT * FROM scores WHERE Name_FK='$Name_FK'";
$query = mysqli_query($linnk, $sqlCommand) or die (mysqli_error());
$count = mysqli_num_rows($query);
if($count > 1) {
$search_output .="$count results for $searchquery";
while($row = mysqli_fetch_array($query)) {
$Candidate_Name_FK = $row["Candidate_Name_FK"];
$search_output .="Item ID: $Candidate_Name_FK <br />";
echo $search_output; //echo to check result
}
} else {
$search_output= "0 results found";
echo $search_output; //echo to check result
}
}
?>
Now edited
variable
$searchquery
not created
I have a search box, and the result will display on the same form.
The problem is I don't know why the result is always "no result", even though the keyword should match some of the records in my database, and the name of the table and column are correct. This is my code:
<html>
<Title>search </title>
<Body>
<form action = " " method = "POST" method = "GET">
<font size = 7 face = "arial rounded MT bold">
WELCOME to VPMG Tradings
</font>
<p align = left>
Enter product name or bar code : <input type = "text" name = "search" > <input type ="submit" name = "searched" value = "Search">
</align>
<br>
<table border = 5 align = center >
<tr><th>Barcode </th><th>Item name </th><th>Description</th><th>Amount</th><th>Stock</th><th>Location</th>
</tr>
<?php
mysql_connect( "localhost" , "admin" , "123") or die(mysql_error());
mysql_select_db("minimart_database") or die(mysql_error());
$output = "";
if (isset ($_POST ["search"] )) {
$searchq = $_POST ["search"];
$searchq = preg_match("/[A-Z | a-z]+/","", $searchq);
$result ="SELECT * FROM stock WHERE ( barcode = '%". $searchq ."') OR (itemname = '% ".$searchq ."')";
$query = mysql_query ($result) or die (mysql_error ());
$count = mysql_num_rows ($query);
if ($count ==0){
$output = 'no results';
}
else{
while ($row = mysql_fetch_array ($query)){
$barcode = $row['barcode'];
$itemname = $row['itemname'];
$description = $row['description'];
$amount = $row['amount'];
$stock = $row['stocks'];
$location = $row['location'];
$output = '<div> '.$barcode.' '.$itemname.' '.$description.' '.$amount.' '.$stock.' '.$location.' </div> ';
}
}
}
?>
<?php print ("$output"); ?>
</table>
</body>
</html>
$searchq = preg_match("/[A-Z | a-z]+/","", $searchq);
makes a string to zero.
Use mysql_real_escape_string($searchq);
and also in query where clause use like instead of =
Sugesstion: Use mysqli/PDO since mysql is deprecated
the code sometimes need to be hard coded to make it work. i used this code to make my search box work and it is working :
<?php
mysql_connect( "localhost" , "admin" , "123") or die(mysql_error());
mysql_select_db("minimart_database") or die(mysql_error());
?>
<form id="home_id" method ="POST" enctype ="multipart/form-data">
<script>
function submitForm(action)
{
document.getElementById('home_id').action=action;
document.getElementById('home_id').submit();
}
</script>
<p align=left><input type="text" name="search" placeholder="enter barcode or item name"><input type="submit" name="searched" onclick="submitForm('finalhome.php')">
<?php
$output="";
if (isset($_POST['search'])){
$searchq=$_POST['search'];
$searchq=mysql_real_escape_string($searchq);
$order="SELECT * FROM stock WHERE barcode LIKE '%$searchq' OR itemname LIKE '%$searchq'";
$result=mysql_query($order);
$count=mysql_num_rows($result);
if ($count>=1){
while($row=mysql_fetch_array($result)){
$barcode=$row['barcode'];
$itemname=$row['itemname'];
$description=$row['description'];
$amount=$row['amount'];
$stocks=$row['stocks'];
$location=$row['location'];
}
$output="<div>'.$barcode.' '.$itemname.' '.$description.' '.$amount.' '.$stocks.' '.$location.' </div>";
}
else
{
$output='no results';
}
}
?>
<?php print("$output"); ?>
Dear Friend i have two function and maybe i might have more in the future but the point is that i want when a user searches for hotel based on postal code on the same text field the function
hotel_by_postel_code($textvalue) should be called and when i search based on country then the function
hotel_by_country($textvalue) should be called. the following is the code that should displays the result however it is not displayong the result as it should at all.
<?php require_once("includes/header.php");?>
<?php require_once("includes/connection.php")?>
<?php
if(isset($_POST['submit'])){
$message ="";
$textvalue = $_POST['search'];
if(empty($allhotels = hotel_by_postel_code($textvalue)) || empty($allhotels = hotel_by_country($textvalue))){
$message = "There is no record in the database";
}
}else{
$allhotels = select_all_hotels();
}
?>
<div class="cBoth"></div>
<div id="sep"></div>
<div id="mainContentSection" class="Calign">
<div id="detaillist">
<div id="searching" class="Calign">
<form action="list2.php" method="POST" id="searchForm">
<fieldset>
<input type="text" name="search" />
<input type="submit" name ="submit" value="Search" /></fieldset>
</form>
</div><!--End of searching-->
<?php
if(isset($message)){
echo"<div id=\"listtitle\">";
echo"<h2>".$message."</h2>";
echo"</div>";//End of listtitle div
}else{
echo"<div id=\"listtitle\">";
echo"<h2>Property Name</h2> <h2>Location</h2> <h2>Guest Rating</h2><h2>Hotel Rank</h2><h2>Per night</h2>";
echo"</div>";
}
?><!--End of listtitle-->
<div class="cBoth"></div>
<?php
$i=0;
while($hotels_set = mysql_fetch_array($allhotels)){
$room_rate = rateforhotel($hotels_set['hotel_id']);
if(!empty( $hotels_set['hotel_name']) && ($room_rate['hotel_id'] == $hotels_set['hotel_id'] ) ){
if($i % 2 == 0) { echo "<div id=\"innerlisteven\">"; }
else
{
echo"<div id=\"innerlistodd\">";
}
echo"<h2>". $hotels_set['hotel_name'] ."</h2>";
echo"<h2>". $hotels_set['country'] ."</h2>";
if(!intval($hotels_set['star'])){
echo"<h2>". $hotels_set['star'] ."</h2>";
}else{
echo"<h2>". $hotels_set['star'] . "<img src=\"img/repetimg/star.png\"/></h2>";
}
echo"<h2>". $hotels_set['star'] . "</h2>";
echo"<h2>". $room_rate['rate'] . "</h2>";
echo"</div>";
$i++;
}//end of if()
}//end of hotel while
mysql_close($con);
?>
</div><!--End of details-->
<div id="advertlisting">
<div id="search">search menu</div>
</div><!--End of adverts left-->
</div><!--End of end of maincontent-->
<div class="cBoth"><!-- clear Both--></div>
<?php require_once("includes/footer.php"); ?>
and the following code is the function itself
function hotel_by_country($country){
global $connection;
$query = "SELECT * FROM Hotels WHERE country ='{$country}'";
$hotel_set = mysql_query($query,$connection);
confirm_query($hotel_set);
return $hotel_set;
}
function hotel_by_postel_code($postal){
global $connection;
$query = "SELECT * FROM Hotels WHERE hotel_postal_code ='{$postal}'";
$hotel_set = mysql_query($query,$connection);
confirm_query($hotel_set);
return $hotel_set;
}
function select_all_hotels(){
global $connection;
$query = "SELECT *
FROM Hotels";
$hotel_set = mysql_query($query,$connection);
confirm_query($hotel_set);
return $hotel_set;
}
You're missing closing (right) brackets ) of the empty functions - one before the OR and one at the end of the condition). Change:
if(empty($allhotels = hotel_by_postel_code($textvalue) OR empty($allhotels = hotel_by_country($textvalue))
to:
if(empty($allhotels = hotel_by_postel_code($textvalue)) OR empty($allhotels = hotel_by_country($textvalue))){
Next, I would break this line into a few lines:
$allhotels1 = hotel_by_postel_code($textvalue);
$allhotels2 = hotel_by_country($textvalue);
echo "allhotels1 = $allhotels1; allhotels1 = $allhotels1\n";//for debug
if(empty($allhotels1) OR empty($allhotels2){...
and one last thing - are you sure it should be OR and not AND ?
if(is_numermic($textvalue))
hotel_by_postel_code($textvalue)
else
hotel_by_country($textvalue)
I think your problem lies in this code
if(empty($allhotels = hotel_by_postel_code($textvalue)) || empty($allhotels = hotel_by_country($textvalue))){
$message = "There is no record in the database";
}
First you fill $allhotels with hotel_by_postel_code($textvalue). Then you overwrite it with $allhotels = hotel_by_country($textvalue).
Also, you should replace the || with && because you only want the message when both functions return no values.
Try
$allhotels = hotel_by_postel_code($textvalue);
if(empty($allhotels)) {
$allhotels = hotel_by_country($textvalue);
if(empty($allhotels)) {
$message = "There is no record in the database";
}
}
After many trail and error i was able to come to the solution and the following is the best option i found maybe in the future someone my come up with the same problem. one thing to keep in mind is that the options in IF and Else can easily be moved into a function on separate file. and i also added one more Html menu to select the type of option i am search for in this case it is the filter menu.
<?php
error_reporting(E_ALL);
ini_set('display_errors','1');?>
<?php require_once("includes/header.php");?>
<?php require_once("includes/connection.php")?>
<?php
if(isset($_POST['search']) && $_POST['search']!= "") {
if($_POST['filter'] == "HotelName"){
$search = $_POST['search'];
$sqlquery = "SELECT * FROM Hotels WHERE hotel_name LIKE '%$search%' OR description LIKE '%$search%'";
$allhotels = mysql_query($sqlquery, $connection) or die("Sorry Something wrong".mysql_error());
}else if($_POST['filter'] == "country"){
$search = $_POST['search'];
$sqlquery = "SELECT * FROM Hotels WHERE country LIKE '%$search%' OR hotel_address LIKE '%$search%'";
$allhotels = mysql_query($sqlquery, $connection) or die("Sorry Something wrong".mysql_error());
}else if($_POST['filter'] == "Postal"){
$search = $_POST['search'];
$sqlquery = "SELECT * FROM Hotels WHERE hotel_postal_code LIKE '%$search%'";
$allhotels = mysql_query($sqlquery, $connection) or die("Sorry Something wrong".mysql_error());
}
}
?>
<div class="cBoth"></div>
<div id="sep"></div>
<div id="mainContentSection" class="Calign">
<div id="detaillist">
<div id="searching" class="Calign">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" id="searchForm">
<fieldset>
<input type="text" name="search" />
<select name="filter">
<option value="HotelName">Hotel Name</option>
<option value="country">Country</option>
<option value="Postal">Postal Code</option>
</select>
<input type="submit" name ="submit" value="Search" />
</fieldset>
</form>
</div><!--End of searching-->
<div id="listtitle">
<h2>Property Name</h2> <h2>Location</h2><h2>Hotel Rank</h2><h2>Guest Rating</h2><h2>Per night</h2>
</div><!--End of listtitle-->
<div class="cBoth"></div>
<?php
if(!isset($allhotels)){
$allhotels = select_all_hotels();
}
$i=0;
while($hotels_set = mysql_fetch_array( $allhotels)){
$room_rate = rateforhotel($hotels_set['hotel_id']);
if(!empty( $hotels_set['hotel_name']) && ($room_rate['hotel_id'] == $hotels_set['hotel_id'] ) ){
if($i % 2 == 0) { echo "<div id=\"innerlisteven\">"; }
else
{
echo"<div id=\"innerlistodd\">";
}
echo"<h2><a href=\"desti_list.php?details=" . urlencode($hotels_set["hotel_id"]).
"\">" . $hotels_set['hotel_name'] ."</a></h2>";
echo"<h2>". $hotels_set['country'] ."</h2>";
if(!intval($hotels_set['star'])){
echo"<h2>". $hotels_set['star'] ."</h2>";
}else{
echo"<h2>". $hotels_set['star'] . "<img src=\"img/repetimg/star.png\"/></h2>";
}
echo"<h2>". $hotels_set['star'] . "</h2>";
echo"<h2>". $room_rate['rate'] . "</h2>";
echo"</div>";
$i++;
/*
echo"<h3><a href=\"desti_list.php?details=" . urlencode($hotels_set["hotel_id"]).
"\">Find Out More</a></span></h3>";
*/
}//end of if()
}//end of hotel while
mysql_close($connection);
?>
</div><!--End of details-->
<div id="advertlisting">
<div id="search">search menu</div>
</div><!--End of adverts left-->
</div><!--End of end of maincontent-->
<div class="cBoth"><!-- clear Both--></div>
<?php require_once("includes/footer.php"); ?>