Problem with IF statement?
Posted: Thu Jul 08, 2010 5:02 am
Hi guys,
A fairly new to php and have come up with a problem during my code.
The code gets events from my database and filters then depending on the 'type'. The problem i'm having is that if the results come back zero. The page doesn't appear. I understand there needs to be an IF statement in there somewhere but each time I have tried I have come across no success.
If anyone has any help, it would be much appreciated
A fairly new to php and have come up with a problem during my code.
The code gets events from my database and filters then depending on the 'type'. The problem i'm having is that if the results come back zero. The page doesn't appear. I understand there needs to be an IF statement in there somewhere but each time I have tried I have come across no success.
Code: Select all
<?
require("connection.php");
if(!(isset($_GET['page']))){
$page = 1;
} else {
$page = $_GET['page'];
}
$type = $_GET['type'];
$result = mysql_query("SELECT * FROM events WHERE type LIKE '%$type%' AND date_order >= CURDATE() ORDER BY date_order");
$rows = mysql_num_rows($result);
$limit = 3;
$last = ceil($rows/$limit);
if ($page < 1) {
$page = 1;
} elseif ($page >$last) {
$page = $last;
}
$max = "LIMIT " . ($page - 1) * $limit . "," . $limit;
$result = mysql_query("SELECT * FROM events WHERE type LIKE '%$type%' AND date_order >= CURDATE() ORDER BY date_order $max") or die();
?>