Location: PHPKode > projects > PHP-Comics > php-comics/suggestions.php
<?php
    include('inc/inc.php');
	$time = time();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title>PHP Comics : Suggestions</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/suggestions.css" />
</head>
<body>
	<?=site::showsidemenu();?>
<h1>Suggestions</h1>
<table class="suggestions">
	<?php $result = DB::Query("SELECT COUNT(bm.Time) as count,b.ID,b.Name,f.Path FROM Bookmark bm, Book b, Folder f WHERE bm.Book = b.ID AND b.Folder = f.ID GROUP BY b.ID ORDER BY count DESC LIMIT 1");
	if(mysql_num_rows($result) > 0)
	{
		$row = mysql_fetch_array($result);
	?>
	<tr>
		<td class="description" valign="top">
			Book read by most number of users
		</td>
		<td valign="top">
			<a href="book.php?path=<?=$row['Path']?>&book=<?=$row['Name']?>"><?=img::getcoverpreview($row['ID'],DB::Setting("CoversDirectory",0),$row['Path']."/".$row['Name']);?><?=$row['Name']?></a>
		</td>
	</tr>
	<?php
	}
	?>
	<?php $result = DB::Query("SELECT b.ID,b.Name,f.Path FROM Bookmark bm, Book b, Folder f WHERE bm.Book = b.ID AND b.Folder = f.ID GROUP BY b.ID ORDER BY bm.Time DESC LIMIT 5");
	if(mysql_num_rows($result) > 0)
	{

	?>
	<tr>
		<td class="description" valign="top">
			Books Read Most Recently
		</td>
		<td valign="top">
			<?php while($row = mysql_fetch_array($result))
			{?>
			<a href="book.php?path=<?=urlencode($row['Path'])?>&book=<?=urlencode($row['Name'])?>"><?=img::getcoverpreview($row['ID'],DB::Setting("CoversDirectory",0),$row['Path']."/".$row['Name']);?><?=$row['Name']?></a><br/><?php } ?>
		</td>
	</tr>
	<?php

	}
	?>
	<?php $result = DB::Query("SELECT b.ID,b.Name,f.Path FROM Book b, Folder f WHERE b.Folder = f.ID AND b.ID NOT IN (SELECT Book FROM Bookmark) GROUP BY b.ID ORDER BY RAND() DESC LIMIT 5");
	if(mysql_num_rows($result) > 0)
	{
	?>
	<tr>
		<td class="description" valign="top">
			A Book Read By No One Before
		</td>
		<td valign="top">
			<?php while($row = mysql_fetch_array($result))
			{?>
			<a href="book.php?path=<?=urlencode($row['Path'])?>&book=<?=urlencode($row['Name'])?>"><?=img::getcoverpreview($row['ID'],DB::Setting("CoversDirectory",0),$row['Path']."/".$row['Name']);?><?=$row['Name']?></a><br/><?php } ?>		</td>
	</tr>
	<?php
	}
	?>
	<?php $result = DB::Query("SELECT b.ID,b.Name,f.Path FROM Bookmark bm, Book b, Folder f WHERE bm.Book = b.ID AND b.Folder = f.ID AND bm.IsRead = 0 AND bm.UID = $_SESSION[UID] ORDER BY RAND() DESC LIMIT 5");
	if(mysql_num_rows($result) > 0)
	{
	?>
	<tr>
		<td class="description" valign="top">
			A Book You Started But Never Finished
		</td>
		<td valign="top">
			<?php while($row = mysql_fetch_array($result)){?>
			<a href="book.php?path=<?=urlencode($row['Path'])?>&book=<?=urlencode($row['Name'])?>"><?=img::getcoverpreview($row['ID'],DB::Setting("CoversDirectory",0),$row['Path']."/".$row['Name']);?><?=$row['Name']?></a><br/><?php } ?>		</td>
	</tr>
	<?php
	}
	?>
	<?php $result = DB::Query("SELECT b.ID,b.Name,f.Path FROM Bookmark bm, Book b, Folder f WHERE bm.Book = b.ID AND b.Folder = f.ID AND bm.IsRead = 1 AND bm.UID = $_SESSION[UID] ORDER BY RAND() DESC LIMIT 5");
	if(mysql_num_rows($result) > 0)
	{

	?>
	<tr>
		<td class="description" valign="top">
			A Book You've Finished Before. Why Not Read it Again?
		</td>
		<td valign="top">
			<?php while($row = mysql_fetch_array($result)){?>
			<a href="book.php?path=<?=urlencode($row['Path'])?>&book=<?=urlencode($row['Name'])?>"><?=img::getcoverpreview($row['ID'],DB::Setting("CoversDirectory",0),$row['Path']."/".$row['Name']);?><?=$row['Name']?></a><br/><?php } ?>		</td>
	</tr>
	<?php
	}
	?>
	<?php $result = DB::Query("SELECT b.ID,b.Name,f.Path FROM Bookmark bm, Book b, Folder f WHERE bm.Book = b.ID AND b.Folder = f.ID AND bm.IsRead = 1 AND b.ID NOT IN (SELECT ID FROM Book b, Bookmark bm WHERE bm.Book = b.ID AND bm.UID = $_SESSION[UID])  GROUP BY b.ID ORDER BY RAND() DESC  LIMIT 5");
	if(mysql_num_rows($result) > 0)
	{

	?>
	<tr>
		<td class="description" valign="top">
			A Book Other People have finished that you haven't.
		</td>
		<td valign="top">
			<?		while($row = mysql_fetch_array($result))
		{?>
			<a href="book.php?path=<?=urlencode($row['Path'])?>&book=<?=urlencode($row['Name'])?>"><?=img::getcoverpreview($row['ID'],DB::Setting("CoversDirectory",0),$row['Path']."/".$row['Name']);?><?=$row['Name']?></a><br/><?php } ?>		</td>
	</tr>
	<?php
	}
	?>
</table>

</body>
</html>
Return current item: PHP-Comics