Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Location
    North Wales
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post How do you filter search results

    Hi all I have these search results in the table below, how do I filter them so they only display a certain county ie :- Cornwall



    Code:
    <table width="680" border="0" cellspacing="8" cellpadding="1" style="margin:0 0 20px 8px;">
      <tr>
        <td align="left" valign="top" width="207"><img src="upimage/thumb/<?php echo $rowg['gallery'];?>" alt="" height="150" width="200"/></td>
        <td><p><strong>Caravan Park</strong> : <?php if($rowr['park_name']!=""){?><?php echo $rowr['park_name'];?><?php } else { ?><?php echo $rowr['caravan_park_list'];?><?php } ?></p>
    	    <p><?php echo $rowr['overview_caravan'];?></p>
    		
    		<p><strong>County</strong> : <?php echo $rowr['County1'];?></p></br> 
    		<!--<p><strong><a href="advanced_search_details.php?gid=<?php echo $rowr['cav_id'];?>" style="text-decoration:none; color:#c36000;">View Details</a></strong> </p>-->
            
            <form name="titlecheck_<?php echo $rowr['cav_id']?>" id="titlecheck_<?php echo $rowr['cav_id']?>" method="post" action="carvan/<?php echo str_replace(" ","-",$rowr['park_name']."/".$uktown."/".$rowr['cav_id']);?>">
            <input type="hidden" name="title_val" value="<?php echo $rowr['cav_id']?>" />
            
            <p><strong><a href="#" onclick="document.titlecheck_<?php echo $rowr['cav_id']?>.submit(); return false;" style="text-decoration:none; color:#c36000;">View Details</a></strong> </p></form>
    	</td>
       </tr>
      </table>
      
       
       <table width="700" border="0" cellspacing="1" cellpadding="1">
        <tr>
        <td colspan="2" align="center"><font color="#990000"><?php echo $msg;?></font></td>
        
       </tr>
      </table>
    
    
    <div style="font-size:15px; line-height:10px; font-weight:bold; margin-top:10px;" align="center"><?php echo $pager->renderFullNav();?></div>

  • #2
    New Coder
    Join Date
    Sep 2011
    Posts
    63
    Thanks
    0
    Thanked 7 Times in 7 Posts
    If you are getting the data from a database you just need to edit your query with a WHERE clause.

    For example

    SELECT * FROM `caravan_parks` WHERE county="cornwall"

    If i could see your PHP I could give you a better answer

  • Users who have thanked davidjones1990 for this post:

    pfereday (06-24-2013)

  • #3
    New to the CF scene
    Join Date
    Jun 2013
    Location
    North Wales
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    The page below displays the table of results
    Code:
    <?php
    ob_start();
    @session_start();
    $conn = mysql_connect("localhost","kensing2_kensing","kensing");
    if (!$conn)
      {  die('Could not connect: ' . mysql_error()); }
      else  {  mysql_select_db('kensing2_kensing2',$conn);
      }
    ?>  
    
    <?php include("include/advand_search2.php");?>
    and this is the table page advand_search2.php

    Code:
    <?php
    ob_start();
    @session_start();
    $conn = mysql_connect("localhost","kensing2_kensing","kensing");
    if (!$conn)
      {  die('Could not connect: ' . mysql_error()); }
      else  {  mysql_select_db('kensing2_kensing2',$conn);
      }
    ?>  
       <table width="680" border="0" cellspacing="8" cellpadding="1" style="margin:0 0 20px 8px;">
      <tr>
        <td align="left" valign="top" width="207"><img src="upimage/thumb/<?php echo $rowg['gallery'];?>" alt="" height="150" width="200"/></td>
        <td><p><strong>Caravan Park</strong> : <?php if($rowr['park_name']!=""){?><?php echo $rowr['park_name'];?><?php } else { ?><?php echo $rowr['caravan_park_list'];?><?php } ?></p>
    	    <p><?php echo $rowr['overview_caravan'];?></p>
    		
    		<p><strong>County</strong> : <?php echo $rowr['County1'];?></p></br> 
    		<!--<p><strong><a href="advanced_search_details.php?gid=<?php echo $rowr['cav_id'];?>" style="text-decoration:none; color:#c36000;">View Details</a></strong> </p>-->
            
            <form name="titlecheck_<?php echo $rowr['cav_id']?>" id="titlecheck_<?php echo $rowr['cav_id']?>" method="post" action="carvan/<?php echo str_replace(" ","-",$rowr['park_name']."/".$uktown."/".$rowr['cav_id']);?>">
            <input type="hidden" name="title_val" value="<?php echo $rowr['cav_id']?>" />
            
            <p><strong><a href="#" onclick="document.titlecheck_<?php echo $rowr['cav_id']?>.submit(); return false;" style="text-decoration:none; color:#c36000;">View Details</a></strong> </p></form>
    	</td>
       </tr>
      </table>
      
       
       <table width="700" border="0" cellspacing="1" cellpadding="1">
        <tr>
        <td colspan="2" align="center"><font color="#990000"><?php echo $msg;?></font></td>
        
       </tr>
      </table>

  • #4
    New Coder
    Join Date
    Sep 2011
    Posts
    63
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Not sure if I missed it but I cant see where you get $rowr from??

  • #5
    New to the CF scene
    Join Date
    Jun 2013
    Location
    North Wales
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry David my fault Wrong contents of advand_search2.php
    file proper contents below

    Code:
    <?php include('ps_pagination4.php');?>
    
    <?php $name = $_REQUEST['search'];?>
    	
    <?php
    		      /*$sqlr = "select * from `general_information`,`facilities_add`,`gallery`,` price_range` where general_information.gid = facilities_add.gid AND facilities_add.gid = gallery.gid AND gallery.gid =  price_range.gid";*/
    			//echo "=====<br/>";  print_r($_REQUEST);echo "=====<br/>";
    			
    			$area 			= 		$_REQUEST['country'];
    			
    			$Country 		= 		$_REQUEST['state'];
    			$Town 			= 		$_REQUEST['town'];
    			$ukTown 			= 		$_REQUEST['uktown'];
    			
    			
    			
    				
    			   $sql = "select * from `caravan_details` where 1";
    				
    				$paramStr = "param1=value1&";
    				
    				if($area !=""){
    					$sql .= " AND Region LIKE '%$area%'";
    					$paramStr .= "&country={$area}";
    				}
    				
    				if($Country !=""){
    					$sql .= " AND County1 LIKE '%$Country%'";
    					$paramStr .= "&state={$Country}";
    				}
    				if($Town !=""){
    					//$sql .= " AND ((city_town LIKE '%$Town%') OR (Town_list LIKE '%$Town%'))"; 
    					$sql .= " AND (park_city LIKE '%$Town%')"; 
    					$paramStr .= "&town={$Town}";
    				}
    				if($ukTown !=""){
    					$sql .= " AND (Town_list LIKE '%$ukTown%')";
    					$paramStr .= "&uktown={$ukTown}";
    				}
    			
    				
    				$sql .= " AND status = 'approve'"; 
    				$sql .= " group by cav_id desc"; 
    			    $sqlr = $sql;
    				
    			    //echo $sqlr;exit();
    				
    				$msg = "No Record Found Here.....";
    				
    				
    				//////////========================= added ednd on 20-09-2012 =====================================================////////
    				
    				
    			    $resr = mysql_query($sqlr) or die(mysql_error());
    			  
    			    $innum = mysql_num_rows($resr);
    				
    				$pager = new PS_Pagination($conn, $sqlr, 10, 10, "{$paramStr}");
    
                    $pager->setDebug(true);
    
                    $res22 = $pager->paginate();
    				
    				if($innum>0)
    				{
    				       
    				while($rowr = mysql_fetch_array($res22))		
    		       {
    			        $gid = $rowr['cav_id'];
    			   		$sqlg = "select * from `gallery` where cav_id='$gid'";
    					$resg = mysql_query($sqlg);
    					$rowg = mysql_fetch_array($resg);
    		?>
    <div class="clear-all">
       <table width="680" border="0" cellspacing="8" cellpadding="1" style="margin:0 0 20px 8px;">
      <tr>
        <td align="left" valign="top" width="207"><img src="upimage/thumb/<?php echo $rowg['gallery'];?>" alt="" height="150" width="200"/></td>
        <td><p><strong>Caravan Park</strong> : <?php if($rowr['park_name']!=""){?><?php echo $rowr['park_name'];?><?php } else { ?><?php echo $rowr['caravan_park_list'];?><?php } ?></p>
    	    <p><?php echo $rowr['overview_caravan'];?></p>
    		
    		<p><strong>County</strong> : <?php echo $rowr['County1'];?></p></br> 
    		<!--<p><strong><a href="advanced_search_details.php?gid=<?php echo $rowr['cav_id'];?>" style="text-decoration:none; color:#c36000;">View Details</a></strong> </p>-->
            <?php
    			$uktown = $rowr['Town'];
    			
    			if ($rowr['city_town']) {
    				$uktown = str_replace(" ","-",$rowr['city_town']);
    			} else if ($rowr['Town_list']) {
    				$uktown = str_replace(" ","-",$rowr['Town_list']);
    			} 
    			
    			if( empty($rowr['park_name']) ) {
    				$rowr['park_name'] = str_replace(" ","-",$rowr['Park_Address1']); 
    				$rowr['park_name'] = str_replace(",","",$rowr['Park_Address1']);
    				if(empty($rowr['park_name']))
    				$rowr['park_name'] = $uktown;
    			}
    			
    			
    		 ?> 
            <form name="titlecheck_<?php echo $rowr['cav_id']?>" id="titlecheck_<?php echo $rowr['cav_id']?>" method="post" action="carvan/<?php echo str_replace(" ","-",$rowr['park_name']."/".$uktown."/".$rowr['cav_id']);?>">
            <input type="hidden" name="title_val" value="<?php echo $rowr['cav_id']?>" />
            
            <p><strong><a href="#" onclick="document.titlecheck_<?php echo $rowr['cav_id']?>.submit(); return false;" style="text-decoration:none; color:#c36000;">View Details</a></strong> </p></form>
    	</td>
       </tr>
      </table></div>   
      <?php
       }
      } 
     else
       {
       ?>
       
       <table width="700" border="0" cellspacing="1" cellpadding="1">
        <tr>
        <td colspan="2" align="center"><font color="#990000"><?php echo $msg;?></font></td>
        
       </tr>
      </table>
      <?php
      }
      ?>
       
       
    
    
    
    <div style="font-size:15px; line-height:10px; font-weight:bold; margin-top:10px;" align="center"><?php echo $pager->renderFullNav();?></div>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •