Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.01 Frameset//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/>
- <title>Book Search</title>
- </head>
- <body style="font-family:Verdana; font-size:0.8em; background-color:darkgrey;">
- <form action="booksearch.php" method="post">
- <table border="0" cellspacing="1" style="font-family:Verdana; font-size:0.9em">
- <tr style="background-color:darkgrey; color:black">
- <th>Book Title<br/><input name="Title" size="30" value="<?php echo $_POST['Title'];?>"></th>
- <th>Author<br/><input name="Author" size="25" value="<?php echo $_POST['Name'];?>"></th>
- <th>ISBN<br/><input name="ISBN Seperated by Hyphens" value="<?php echo $_POST['ISBN'];?>"></th>
- <th>Rating<br/><input name="rating" size ="6" value="<?php echo $_POST['Rating'];?>"></th>
- <th>sort by <select size="1" name="sort" value="sort by">
- <option value="Title" <?php if ($_POST['sort'] == 'Title') echo "selected='selected'";?>>Title</option>
- <option value="Author" <?php if ($_POST['sort'] == 'Name') echo "selected='selected'";?>>Author</option>
- <option value="isbn" <?php if ($_POST['sort'] == 'ISBN') echo "selected='selected'";?>>ISBN</option>
- <option value="rating desc" <?php if ($_POST['sort'] == 'rating desc') echo "selected='selected'";?>>Rating descending</option>
- </select>
- <input type="submit" name="searching" value="Search"/>
- </th>
- </tr>
- <?php
- $i = 1;
- if (isset($_POST["searching"]))
- {
- mysql_connect("localhost", "root","maus2007");
- mysql_select_db("books");
- $sqlab = "select rating, book, name, title, isbn, author";
- $sqlab .= " from books, ratings, authors";
- $sqlab .= " where book.rating=id.books";
- $sqlab .= " and id.authors = author.books";
- $sqlab .= " and id.books = book.ratings";
- if ($_POST["title"] != "")
- $sqlab .= " and (title like'%" . $_POST["Title"] . "%'";
- if ($_POST["name"] != "")
- $sqlab .= " and (name like '%" . $_POST["Author"] . "%')";
- if ($_POST["isbn"] != "")
- $sqlab .= " and isbn.books'". $_POST["isbn"] . "'";
- if ($_POST["rating"] != "")
- $sqlab .= " and avg(rating) <= '" . $_POST["rating"] . "'" . "or avg(rating) >= '" . $_POST["rating"] . "'";
- if ($_POST["sort"] != '0')
- $sqlab .= " order by " . $_POST["sort"];
- $res = mysql_query($sqlab);
- $farbe[0] = "ffcc66";
- $farbe[1] = "ffff99";
- while ($dsatz = mysql_fetch_assoc($res))
- {
- echo "<tr style='background-color:" . $farbe[$i] . "' align='center'>\n";
- echo " <td>" . $dsatz["title"] . "</td>\n";
- echo " <td>" . $dsatz["name"] . "</td>\n";
- echo " <td align='left'>" . $dsatz["isbn"] . "</td>\n";
- echo " <td>" . $dsatz["rating"] . "</td>\n";
- echo " <td> </td>\n";
- echo "</tr>\n";
- $i = 1 - $i;
- }
- }
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement