please help on this

admin

Administrator
Staff member
If I try to run query from phpmyadmin I get right result but if I try with php I get all matches. please

help telling me how to correct script

searchform.php looking:


<body>
<br>
<form name="Services" method="POST" action="search.php">
<table width="400" border="0">
<tr>
<td><input type="checkbox" name="Services[]" value=http://www.phpbuilder.com/board/archive/index.php/"">TV</td>
<td><input type="checkbox" name="Services[]" value="">pool</td>
<td><input type="checkbox" name="Services[]" value="">minibar</tr>
<tr><td><input type="checkbox" name="Services[]" value="">Tennis</td>
<td><input type="checkbox" name="Services[]" value="">babysittig</td>
</tr></table>
<br><p>Hotel:
<input type=text name=Nome size=25 maxlength=25>
Category:
<select name="Category">
<option>one star</option>
<option>two stars</option>
<option>three stars</option>
<option>four starse</option>
</select>
</p>
<p>Address
<input type=text name=Indirizzo size=25 maxlength=25>
Locality;
<input type=text name=Locality; size=25 maxlength=25>
</p>
<input type="submit" value="Submit">
</form>
</body>


and search.php looking:

<body>

<?php

mysql_connect (localhost, user, pass);

mysql_select_db (hotelsearch);

if ($Localit?== "")
{$Localit?='%';}

if ($Categoria == "")
{$Categoria = '%';}

if ($Servizi == "")
{$Servizi = '%';}

$result = mysql_query ("SELECT DISTINCT Hotel.Name,Address, Category.Category FROM Hotel,
Services,Category, Hoteldetail WHERE Hoteldetail.IDHotel = Hotel.IDHotel AND Hoteldetail.IDServices =
Services.IDServices AND Hoteldetail.IDCategory=Category.IDCategory AND Servicies.IDServicies LIKE '%'
AND Category.IDCategory LIKE '%' ");

if ($row = mysql_fetch_array($result)) {

do {
print $row["Name"];
print (" ");
print $row["Category"];
print (" ");
print $row["Locality"];
print (" ");
print $row["Address"];
print ("<p>");
print $row["Services"];
print (" ");
} while($row = mysql_fetch_array($result));

} else {print "Sorry, no records were found!";}

?>

</body>


Database has those tables:
1)category (IDCategory,Category,pics)
2)Hotel (IDhotel,name,category,IDLocality,address,pic)
3)Hotel Detail (IDHoteldetail,IDhotel,IDservice,IDlocality,IDCategory)
4)Locality (IDlocality,locality)
5)Services (IDservice,service)

thank in advance for helping
 
Back
Top