Two of the field entries are exactly the same.
I have a page called 'search.php' which has several forms.
Now the first two forms on that page are text entry. Now, when I type the correct spelling of either of the entries it doesn't show anything. But when I type in another of the text input with the Author the same as the two entries, only one of them shows, and the first one doesn't show. The code for search.php is shown below...
Code: Select all
<html>
<head>
<body>
<div id='searchbox'>
<br /><h1>Book Search</h1><br />
<form action="books.php" method='POST'>
Book Title:
<input type="text" name="books">
<INPUT type="submit" name="go" value="Search!">
</form>
<br /><br />
<form action="books.php" method='POST'>
Author:
<input type="text" name="author">
<INPUT type="submit" name="go" value="Search!">
</form>
<br /><br />
<form action="books.php" method='POST'>
Price:
<select name="price">
<option value="nothing"></option>
<option value="£1.99">£1.99</option>
<option value="£2.99">£2.99</option>
<option value="£3.99">£3.99</option>
<option value="£4.99">£4.99</option>
<option value="£5.99">£5.99</option>
<option value="£6.99">£6.99</option>
<option value="£7.99">£7.99</option>
<option value="£8.99">£8.99</option>
<option value="£9.99">£9.99</option>
<option value="£10.99">£10.99</option>
</select>
<INPUT type="submit" name="go" value="Search!">
</form>
<br /><br />
<form action="books.php" method='POST'>
Publication Year:
<select name="year">
<option value="nothing"></option>
<option value="1810">1810</option>
<option value="1820">1820</option>
<option value="1830">1830</option>
<option value="1840">1840</option>
<option value="1850">1850</option>
<option value="1860">1860</option>
<option value="1870">1870</option>
<option value="1880">1880</option>
<option value="1890">1890</option>
<option value="1900">1900</option>
<option value="1940">1940</option>
</select>
<INPUT type="submit" name="go" value="Search!">
</form>
<br /><br />
<form action="books.php" method='POST'>
Country of Origin:
<select name="origin">
<option value="nothing"></option>
<option value="UK">UK</option>
<option value="America">America</option>
<option value="Australia">Australia</option>
<option value="Germany">Germany</option>
<option value="France">France</option>
<option value="Spain">Spain</option>
<option value="Russia">Russia</option>
<option value="Argentina">Argentina</option>
<option value="Denmark">Denmark</option>
<option value="Fiji">Fiji</option>
</select>
<INPUT type="submit" name="go" value="Search!">
</form>
<br /><br />
<form action="books.php" method='POST'>
Condition:
<select name="condition">
<option value="nothing"></option>
<option value="used">Used</option>
<option value="new">New</option>
</select>
<INPUT type="submit" name="go" value="Search!">
</form>
</div>
<?php
$book=$_POST['books'];
$author=$_POST['author'];
$price=$_POST['price'];
$year=$_POST['year'];
$origin=$_POST['origin'];
$condition=$_POST['condition'];
?>
</body>
</html>
The code shown below is 'books.php'...
Code: Select all
<?php
$result = mysql_query("SELECT * FROM books WHERE Book_Title='$books' or Author='$author' or Price='$price' or Publication_Year='$year' or Origin_Country='$origin' or Condition='$condition'")
or die(mysql_error());
$row = mysql_fetch_array( $result );
echo "<table border='0' align='center' style='background-color: #153E7E;border: 1px solid #ffffff;color: #ffffff;font-family: verdana, sans-serif;font-size: 14px;font-weight: 900;'>";
echo "<tr> <th class='styled' style='border-left:none;'>Book Title</th> <th class='styled'>Author</th> <th class='styled'>Price</th> <th class='styled'>Year of Publication</th> <th class='styled'>Country of Origin</th> <th class='styled'>Condition</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row
echo "<tr><td class='styles' style='border-left: none;'>";
echo $row['Book_Title'];
echo "</td><td class='styles'>";
echo $row['Author'];
echo "</td><td class='styles'>";
echo $row['Price'];
echo "</td><td class='styles'>";
echo $row['Publication_Year'];
echo "</td><td class='styles'>";
echo $row['Origin_Country'];
echo "</td><td class='styles'>";
echo $row['Condition'];
echo "</td></tr>";
}
echo "</table>";
?>
Visit the search page here. You can then type in 'Dan Brown' for the author search field, and then click on search. This will display one field.
However, there are two rows of data in the table, and they both have 'Dan Brown' as the author. Also, when typing either of the book titles into the appropriate field nothing shows up.
I would be very greatful is someone could help me out with my problem.