Jump to content

Category Listing : date filter


mihirc

Recommended Posts

Hey all,

I just joined this forum so thank you! :) I am a regular contributor over at CssCreator.com, but i got stuck at a php problem and so came here to seek some guidance from you folks!

 

I am working on a new site project at foliageoutdoors.com/newsite.

This site is a travel company that i work for and its got fixed departure tours to different destination. 1 destination can i have multiple departures (batch).

So i have split my table structure like this -

Destination

id, title, description, etc

Batch

id, destination_id, datefrom, dateto, charges, etc

Here is my problem :

 

When i go to a listing, I want to show all destinations with batches starting from tomorrow+.

I have written the sql queries, but they are not doing what i want. It would really help if someone can help me out with this! I want someone to look at the complete code, so please PM / reply me and i will share the file.

 

<?php
	$todaysdate = date("Y-m-d H:i:s");
	$category = $_GET['title'];
        $getcategory = "SELECT destination.*, batch.* FROM `destination` LEFT JOIN batch ON destination.id = batch.destination_id WHERE destination.category = '".$category."' GROUP BY batch.destination_id";
        $result = mysql_query($getcategory);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Foliage Outdoors.com | <?php echo $category; ?></title>
<link rel="stylesheet" href="http://<? echo $topsiteurl; ?>/css/structure.css" type="text/css"/>
<link rel="stylesheet" href="http://<? echo $topsiteurl; ?>/css/category.css" type="text/css"/>

</head>

<body>
<div id="maincontainer">
	<div id="header">
	<?php include_once($_SERVER['DOCUMENT_ROOT'].'/newsite/includes/header.php') ?>
        </div>
        <div id="bodycontainer">
        
		<?
        while ($db_row = mysql_fetch_assoc($result)) {
		$id = $db_row['id']; 
		$desc = $db_row['desc'];           
		$siteurl = $_SERVER['SERVER_NAME'];
		$title = $db_row['title'];
		$url = $db_row['url'];
		$photo = $db_row['photo'];

		$highlights = $db_row['highlights'];
            echo("<div class='camp'><div class='title'><img src='http://".$topsiteurl.'/images/destinations/'.$photo.".jpg' class='Destination Images' alt = '".$photo."' />
		<a href=http://".$topsiteurl.'/destinations/destinations.php?id='.$id.">".$title."</a></div>
		<div class='description'>".$highlights."</div>");


		$getbatch ="SELECT * FROM batch WHERE destination_id = ".$id." AND date_from > '".$todaysdate."'";
		$result2 = mysql_query($getbatch);
		echo ("<div class='dates'>Batch Dates:<br />");
			while ($db_row=mysql_fetch_assoc($result2)){ 
			$batchfrom = $db_row['date_from'];
			$newDate = date("j-F-Y", strtotime($batchfrom));
			$batchto = $db_row['date_to'];
			$EndwDate = date("j-F-Y", strtotime($batchto));
			$code = $db_row['code'];
			$campfor = $db_row['campfor'];

			$diff = abs(strtotime($EndwDate) - strtotime($newDate));
			$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));

		if ($newDate != '') { 
		echo ("".$newDate." - ".$EndwDate."||".$days."(days)<br />"); }
		else { 
		 echo ("<div>Sorry! There are no batches scheduled currently! Contact us for a custom tour</div>");
			}};
       echo ("</div><div class='gallery'>Photo-Gallery | Video Gallery</div></div>");}

        mysql_close();
?>
</div>
</div>
</div>
</body>
</html>

 

Regards,

Mihir.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.