Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.79 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.01 Frameset//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/>
  5. <title>Book Search</title>
  6. </head>
  7. <body  style="font-family:Verdana; font-size:0.8em; background-color:darkgrey;">
  8. <form action="booksearch.php" method="post">
  9. <table border="0" cellspacing="1"  style="font-family:Verdana; font-size:0.9em">
  10.     <tr style="background-color:darkgrey; color:black">
  11.         <th>Book Title<br/><input name="Title" size="30" value="<?php echo $_POST['Title'];?>"></th>
  12.         <th>Author<br/><input name="Author" size="25" value="<?php echo $_POST['Name'];?>"></th>
  13.         <th>ISBN<br/><input name="ISBN Seperated by Hyphens" value="<?php echo $_POST['ISBN'];?>"></th>
  14.         <th>Rating<br/><input name="rating" size ="6" value="<?php echo $_POST['Rating'];?>"></th>
  15.         <th>sort by <select size="1" name="sort" value="sort by">
  16.                 <option value="Title" <?php if ($_POST['sort'] == 'Title') echo "selected='selected'";?>>Title</option>
  17.                 <option value="Author" <?php if ($_POST['sort'] == 'Name') echo "selected='selected'";?>>Author</option>
  18.                 <option value="isbn" <?php if ($_POST['sort'] == 'ISBN') echo "selected='selected'";?>>ISBN</option>
  19.                 <option value="rating desc" <?php if ($_POST['sort'] == 'rating desc') echo "selected='selected'";?>>Rating descending</option>
  20.             </select>
  21.             <input type="submit" name="searching" value="Search"/>
  22.         </th>
  23.     </tr>
  24. <?php
  25.  
  26.     $i = 1;
  27.     if (isset($_POST["searching"]))
  28.     {
  29.         mysql_connect("localhost", "root","maus2007");
  30.         mysql_select_db("books");
  31.        
  32.         $sqlab  = "select rating, book, name, title, isbn, author";
  33.         $sqlab .= " from books, ratings, authors";
  34.         $sqlab .= " where book.rating=id.books";
  35.         $sqlab .= " and id.authors = author.books";
  36.         $sqlab .= " and id.books = book.ratings";
  37.        
  38.         if ($_POST["title"] != "")
  39.             $sqlab .= " and (title like'%" . $_POST["Title"] . "%'";
  40.         if ($_POST["name"] != "")
  41.             $sqlab .= " and (name like '%" . $_POST["Author"] . "%')";
  42.         if ($_POST["isbn"] != "")
  43.             $sqlab .= " and isbn.books'". $_POST["isbn"] . "'";
  44.         if ($_POST["rating"] != "")
  45.             $sqlab .= " and avg(rating) <= '" . $_POST["rating"] . "'" . "or avg(rating) >= '" . $_POST["rating"] . "'";
  46.         if ($_POST["sort"] != '0')
  47.             $sqlab .= " order by " . $_POST["sort"];
  48.        
  49.         $res = mysql_query($sqlab);
  50.        
  51.         $farbe[0] = "ffcc66";
  52.         $farbe[1] = "ffff99";
  53.         while ($dsatz = mysql_fetch_assoc($res))
  54.         {
  55.             echo "<tr style='background-color:" . $farbe[$i] . "' align='center'>\n";
  56.             echo "   <td>" . $dsatz["title"] . "</td>\n";
  57.             echo "   <td>" . $dsatz["name"] . "</td>\n";
  58.             echo "   <td align='left'>" . $dsatz["isbn"] . "</td>\n";
  59.             echo "   <td>" . $dsatz["rating"] . "</td>\n";
  60.             echo "   <td>&nbsp;</td>\n";
  61.             echo "</tr>\n";
  62.             $i = 1 - $i;
  63.         }
  64.     }
  65. ?>
  66. </table>
  67. </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement