require_once "util/listing.php"; connect(false); $query = 'SELECT * FROM Books ORDER BY ' . $criterion . ' ' . $direction . " LIMIT " . $pos . ", " . $per_page . ""; $resource = mysql_query($query); if ($resource) { $i = 0; while ($row = mysql_fetch_array($resource)) { $addClass = ""; $i++; if ($i % 2 == 0) { $addClass = " color2"; } //alternate colors in display $isbn = $row['ISBN']; $offerbutton = "<p class='offers'><a href=offers.php?isbn={$isbn}>See offers</a></p>"; $newcode = "<div class='item{$addClass}'>" . generateListing_B($isbn, $row['title'], mappedClasses($row['ISBN'])) . $offerbutton . '</div>'; echo $newcode; } $resource2 = mysql_query("SELECT COUNT(*) FROM Books"); if ($resource2) { $total_r = mysql_fetch_row($resource2); $total = $total_r[0]; if ($total - $per_page > $pos) { echo "<div class='item-seller item-info'>"; // temporary formatting - might want a separate class for this echo "<a href='browse.php?page=" . ($page_num + 1) . "&num=" . $per_page . "'>More</a> </div>"; } } } else { echo mysql_error(); }
echo $newcode; } }?> <br /> <p><b>Optional books:</b></p> <? $query="SELECT * FROM CMap WHERE courseId='$cId' AND required='0'"; $resource=mysql_query($query); if($resource) { $i=0; while($row=mysql_fetch_array($resource)) { $addClass = ""; $i++; if ($i%2==0) $addClass = " color2"; //alternate colors in display $isbn=$row['ISBN']; $offerbutton = "<p class='offers'><a href=offers.php?isbn=$isbn>See offers</a></p>"; $newcode = "<div class='item$addClass'>" . generateListing_B($isbn, mappedTitle($row['ISBN']), mappedClasses($row['ISBN'])) . $offerbutton . '</div>'; echo $newcode; } } ?> </div> <? require("util/footer.php"); ?> </body> </html> <!-- Authors: Derek Leung, Ben Chan Project BellBook - 1.0 Bellarmine College Preparatory, 2011 -->