if ($page > $max) { $page = 1; } // Do SELECT from a table $sql = "SELECT * FROM VMovie LIMIT {$hits} OFFSET " . ($page - 1) * $hits; $res = $db->ExecuteSelectQueryAndFetchAll($sql); //print hit-buttons echo "<p>" . getHitsPerPage(array(1, 2, 3, 4, 5, 10)) . "<a href='?p=paginate' class='aButton'>Visa alla</a></p>"; ?> <table class='table'> <tr><th>Rad</th><th>Id</th><th>Bild</th><th>Titel</th><th>År</th></tr> <?php foreach ($res as $i => $row) { echo "<tr><td style='width:10%;'>{$i}</td><td style='width:10%;'>{$row->id}</td>" . "<td style='width:15%;'><img src='{$row->image}' alt='bild på film' width='100' height='50'></td>" . "<td>{$row->title}</td><td style='width:10%;'>{$row->year}</td></tr>"; } ?> </table> <div style="text-align: center; margin-top: 5px;"> <?php //print page navigation echo getPageNavigation($hits, $page, $max); ?> </div>
if ($folder == "inbox") { $rawQuery = "WHERE `to`='{$_SESSION['username']}' AND `unread`='1' ORDER BY `id` ASC"; } else { if ($folder == "sent") { $rawQuery = "WHERE `from`='{$_SESSION['username']}' ORDER BY `id` ASC"; } else { if ($folder == "read") { $rawQuery = "WHERE `to`='{$_SESSION['username']}' AND `unread`='0' ORDER BY `id` ASC"; } } } $query = mysql_query("SELECT * FROM `mail` " . $rawQuery . " LIMIT {$start}, {$perPage}") or die(mysql_error()); $q2 = mysql_query("SELECT * FROM `mail` " . $rawQuery) or die(mysql_error()); $allMail = mysql_num_rows($q2); $maxPages = mysql_result(mysql_query("SELECT COUNT(*) AS `num` FROM `mail` " . $rawQuery), 0, 'num'); $pageLine = getPageNavigation($maxPages, "mail.php", $perPage, 3, "folder={$folder}"); if ($query != null && mysql_num_rows($query) > 0) { while ($a = mysql_fetch_array($query)) { $to = $a['to']; $from = $a['from']; $message = $a['message']; $sent = $a['sent']; $complex = $a['complex']; $unread = $a['unread']; $id = $a['id']; if ($complex == 1) { $complex = true; } else { $complex = false; } if ($unread == 1) {
// Complete the sql statement $where = $where ? " WHERE 1 {$where}" : null; $sql = $sqlOrig . $where . $groupby . $sort . $limit; $res = $db->ExecuteSelectQueryAndFetchAll($sql, $params); // Put results into a HTML-table $tr = "<tr><th>Rad</th><th>Id " . orderby('id') . "</th><th>Bild</th><th>Titel " . orderby('title') . "</th><th>År " . orderby('year') . "</th><th>Genre</th></tr>"; foreach ($res as $key => $val) { $tr .= "<tr><td>{$key}</td><td>{$val->id}</td><td><img width='80' height='40' src='{$val->image}' alt='{$val->title}' /></td><td>{$val->title}</td><td>{$val->year}</td><td>{$val->genre}</td></tr>"; } // Get max pages for current query, for navigation $sql = "\n SELECT\n COUNT(id) AS rows\n FROM \n (\n {$sqlOrig} {$where} {$groupby}\n ) AS Movie\n"; $res = $db->ExecuteSelectQueryAndFetchAll($sql, $params); $rows = $res[0]->rows; $max = ceil($rows / $hits); $hitsPerPage = getHitsPerPage(array(2, 4, 8), $hits); $navigatePage = getPageNavigation($hits, $page, $max); $sqlDebug = $db->Dump(); ?> <h1 class="center">Sök efter en film </h1> <form method="get"> <input type=hidden name=p value='moviesearchall'/> <input type=hidden name=hits value='<?php echo $hits; ?> '/> <input type=hidden name=page value='1'/> <p><label>Titel (eller del av titel): <input type='search' autofocus="autofocus" name='title' value='<?php