Hi ,
I am having a list of checkboxes ,each of them having some values in mysql database.
If we click on any two or three check boxes,i should get the data from the respective tables.
and should be hidden if i uncheck the checkboxes.
This is just like searching the jobs based on two locations,and with salary range.

I am searching for a sample code for 3 days.but i couldn't find any.
Please provide me with sample code.
Thanks in advance

Recommended Answers

All 6 Replies

post your work so far,
later you cant use jquery to fetch data without reloading whole page

Member Avatar for diafol

That's quite trivial, so should be easy to get you going. But as urtrivedi states, post your code.

sorry for the late sir.
my complete code is

<?php
include"db.php";
?>
<!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>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="styles/style.css" />
<link rel="stylesheet" href="styles/reveal.css" type="text/css"> 
<script type="text/javascript" src="js/jquery.reveal.js"></script>
<link rel="stylesheet" type="text/css" href="styles/ddsmoothmenu.css" />    
    <script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>
 <script>
 function day(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","feeget.php?q=1);
xmlhttp.send();
}

</script>

<script type="text/javascript" src="js/ddsmoothmenu.js">
</script>

<script type="text/javascript">

ddsmoothmenu.init({
    mainmenuid: "smoothmenu1", //menu DIV id
    orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
    classname: 'ddsmoothmenu', //class added to menu's outer DIV
    //customtheme: ["#1c5a80", "#18374a"],
    contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>



<!----------------------------------------side barmenu script------------------------------------------------>
<script type="text/javascript" src="js/scriptbreaker-multiple-accordion-1.js"></script>
<script language="JavaScript">

$(document).ready(function() {
    $(".topnav").accordion({
        accordion:false,
        speed: 500,
        closedSign: '[+]',
        openedSign: '[-]'
    });
});

</script>
</head>

<body>
  <div id="wrap">
  <?php
include("header.php");
?>


   <div class="cnt_waper">
<!------------------lf_cont start------------------>
<div class="lf_cont">
<div class="side_bar">      
<ul class="topnav">
    <li><a href="#">By Freshness</a>

        <ul>


             <?php
include "db.php";
if(isset($_POST['submit']))
{
    $keyword=$_POST['keyword'];
  $countrydrop = $_POST['countrydrop'];
  $job_loc = $_POST['job_loc'];
  $job_exp = $_POST['job_exp'];
  $months = $_POST['months'];
  $function = $_POST['function'];
  $job_type = $_POST['job_type'];
  $company_type = $_POST['company_type'];
  $job_fresh = $_POST['job_fresh'];


  $result = mysql_query("select * from employer_jobpost where (key_skills LIKE '%$keyword%') or (key_skills LIKE '%$keyword%' and location like '%$job_loc') or (key_skills LIKE '%$keyword%' and max_exp like '%$job_exp' and job_category like '%$function%') or (key_skills LIKE '%$keyword%' and max_exp like '%$job_exp' and job_category like '%$function%' and vacancy_type like '%$job_type%')  ");

 ?>
   <li class="active"><a href="#"><label><input type="checkbox" name="" id="" value=1 onclick="day(this.value)" /></label>
             <label class="catg_name">1 day</label><em>(<?php $date=mysql_query("select * from employer_jobpost where date=(SELECT DATE( NOW( ) ))") ; $val=mysql_fetch_assoc($date); echo mysql_num_rows($date);?>)</em></a></li>

             <li><a href="#"><label><input type="checkbox" name="" id="" value=3 onclick="day(this.value)"/></label>
             <label class="catg_name">3 days</label><em>(<?php $date1=mysql_query("select * from employer_jobpost where date>=(SELECT DATE(DATE_SUB(NOW(), INTERVAL 3 DAY)))") ; $val1=mysql_fetch_assoc($date1); echo mysql_num_rows($date1);?>)</em></a></li>

             <li><a href="#"><label><input type="checkbox" name="" id="" onclick="day()" value=7/></label>
             <label class="catg_name">7 days</label><em>(<?php $date2=mysql_query("select * from employer_jobpost where date>=(SELECT DATE(DATE_SUB(NOW(), INTERVAL 7 DAY)))") ; $val2=mysql_fetch_assoc($date2); echo mysql_num_rows($date2);?>)</em></a></li>

             <li><a href="#"><label><input type="checkbox" name="" id="" onclick="day()"  value=15/></label>
             <label class="catg_name">15 days</label><em>(<?php $date3=mysql_query("select * from employer_jobpost where date>=(SELECT DATE(DATE_SUB(NOW(), INTERVAL 15 DAY)))") ; $val3=mysql_fetch_assoc($date3); echo mysql_num_rows($date3);?>)</em></a></li>

             <li><a href="#"><label><input type="checkbox" name="" id="" onclick="day()" value=30 /></label>
             <label class="catg_name">30 days</label><em>(<?php $date4=mysql_query("select * from employer_jobpost where date>=(SELECT DATE(DATE_SUB(NOW(), INTERVAL 30 DAY)))") ; $val4=mysql_fetch_assoc($date4); echo mysql_num_rows($date4);?>)</em></a></li>
        </ul>
    </li>



     <li><a href="#">By Location</a>
        <ul>
        <?php
        $get=mysql_query("select distinct(location) from employer_jobpost");
        while($getin=mysql_fetch_assoc($get))
        {
        ?>
             <li class="active">
             <a href="#">

             <label><input type="checkbox" name="" id="" /></label>
             <label class="catg_name"><?php echo $getin['location'];?></label><em>(<?php $loc=mysql_query("select * from employer_jobpost where location='".$getin['location']."'") ; echo mysql_num_rows($loc);?>)</em></a></li>

        <?php
        }
        ?>
        </ul>
    </li>
</ul>
</div>
<div class="clear"></div>
</div>
<!------------------lt_cont start------------------>




<!------------------rt_cont start------------------>

<div class="rt_cont">
<?php

  while($info = mysql_fetch_assoc($result))
  {

?>
<!------------------description start------------------>
<div class="lft_desc" id="txtHint">

<div class="title">
    <h1><a href="job-info.php"><?php echo $info['job_title'];  ?></a></h1>

    </div>
    <h3><?php echo $info['company_name']; ?></h3>
    <p><?php echo $info['description']; ?></p>
     <div class="more_info"><a href="applyjob.php?searchid=<?php echo $info['id'];  ?>">Apply Now</a></div>
    <div class="more_info"><a href="job-info.php?searchid=<?php echo $info['id'];  ?>">More Information</a></div>
    <?php
    if($_SESSION['id']!="")
    {

    ?>
     <div class="more_info"><a href="applyjob.php?searchid=<?php echo $info['id'];  ?>">Apply Now</a></div>
     <?php
  }
     ?>

</div>

<?php
  }

}
?>
</div>
<!------------------description end------------------>




<!------------------rt_cont end------------------>
<div class="cleaner"></div>
</div>     





  <div id="footer">
<?php include('footer.php');?>
</div>
<div class="cleaner"></div>      
</div>
<!-------------------------- waper end------------------------------------->
</body>
</html>

If i click on a location and freshness the database values which match both the conditions should be displayed.Please help me.

the values need to change on click.
If possible please provide a good tutorial to complete the task myself.

Thanks

Does anybody have prewritten code for this requirement.Please provide that.I can modify the code as of my requirement.

I think the above code might be uninteresting to read..
Please have look at this modified one and help me.

<?php
include"db.php";
?>
<html>
<head>
 <script>
 function day(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","feeget.php?q=1);
xmlhttp.send();
}

</script>

<script type="text/javascript" src="js/ddsmoothmenu.js">
</script>

<script type="text/javascript">

ddsmoothmenu.init({
    mainmenuid: "smoothmenu1", //menu DIV id
    orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
    classname: 'ddsmoothmenu', //class added to menu's outer DIV
    //customtheme: ["#1c5a80", "#18374a"],
    contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>



<!----------------------------------------side barmenu script------------------------------------------------>
<script type="text/javascript" src="js/scriptbreaker-multiple-accordion-1.js"></script>
<script language="JavaScript">

$(document).ready(function() {
    $(".topnav").accordion({
        accordion:false,
        speed: 500,
        closedSign: '[+]',
        openedSign: '[-]'
    });
});

</script>
</head>

<body>
  <div id="wrap">
  <?php
include("header.php");
?>


   <div class="cnt_waper">

<!------------------lf_cont start------------------>

<div class="lf_cont">
<div class="side_bar">      
<ul class="topnav">

     <li><a href="#">By Location</a>
        <ul>
             <li class="active">
             <a href="#">

             <label><input type="checkbox" name="" id="" /></label>
             <label class="catg_name">Hyderabad</label><em></em></a></li>
             <li class="active">
             <a href="#">

             <label><input type="checkbox" name="" id="" /></label>
             <label class="catg_name">Mumbai</label><em></em></a></li>
        </ul>
    </li>
</ul>
<ul class="topnav">

     <li><a href="#">By Salary</a>
        <ul>
             <li class="active">
             <a href="#">

             <label><input type="checkbox" name="" id="" /></label>
             <label class="catg_name">1-2 lakhs</label><em></em></a></li>
             <li class="active">
             <a href="#">

             <label><input type="checkbox" name="" id="" /></label>
             <label class="catg_name">2-4 lakhs</label><em></em></a></li>
        </ul>
    </li>
</ul>
</div>
<div class="clear"></div>
</div>


<div class="rt_cont">
<?php

  while($info = mysql_fetch_assoc($result))//the info variable consist of query values
  {

?>
<!------------------description start------------------>
<div class="lft_desc" id="txtHint">

<div class="title">
    <h1><a href="job-info.php"><?php echo $info['job_title'];  ?></a></h1>

    </div>
    <h3><?php echo $info['company_name']; ?></h3>
    <p><?php echo $info['description']; ?></p>
     <div class="more_info"><a href="applyjob.php?searchid=<?php echo $info['id'];  ?>">Apply Now</a></div>
    <div class="more_info"><a href="job-info.php?searchid=<?php echo $info['id'];  ?>">More Information</a></div>
    <?php
    if($_SESSION['id']!="")
    {

    ?>
     <div class="more_info"><a href="applyjob.php?searchid=<?php echo $info['id'];  ?>">Apply Now</a></div>
     <?php
  }
     ?>

</div>

<?php
  }


?>
</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.