Header weekly by date column in json - php

sorry about clumsily question,
i'm not really sure it possible, i read data from Mysql db correctly with json
and display them into element that is not table
in database i have some appointment date that will be display to client group by weekly and have next link to other week.
there is some code,i's sorry about lot of that.
here is html code :
<div class="timesviewport">
<div class="selector">
<div class="title-collection" style="">
<!--time add here-->
</div>
<div class="selector-header">
<div class="header-title-collection" style="">
<!--date add here-->
</div>
<div class="control">
<div class="prevlink">
<div class="nextprevloading"></div>
<a class="prevweeklink" href="#" rel="nofollow">before</a>
</div>
<div class="nextlink">
<div class="nextprevloading"></div>
<a class="nextweeklink" href="#" rel="nofollow" data-test="search-next-week-link">next</a>
</div>
</div>
</div>
</div>
</div>
and here is javascript
function getresDetails(id)
{
var new_res_date = '' ;
var new_res_time = '' ;
new_res_time += '<div class="title"><div class="title-row-collection">';
daily = ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"];
j=0;
var id_val = id.value;
var url = "table.php?id="+id_val;
$.getJSON(url, function(json) {
new_res_date +='<div class="header-title"><div class="header-title-date-collection" id="adddate">';
new_res_time += '<div class="title-row"><div class="title-row-date-collection">' ;
$.each(json, function(i, value) {
if(i==0)
{
new_res_date += '<div class="header-title-date"><div class="header-title-date-name">'+daily[j%7]+ '</div><div class="header-title-date-value">'+json[i].res_date+ '</div></div>';
new_res_time += '<div class="title-row-date"><div class="appointment-collection"><div class="appointment-collection-first"><div><a class="appointment-time" href="#">'+json[i].res_time+'</a></div>' ;
//alert("first :" +i);
j++;
}
else if (i>0 && json[i-1].res_date==json[i].res_date)
{
new_res_time += '<div><a class="appointment-time" href="#">'+json[i].res_time+ '</a></div>';
//alert("second :" +i);
}
else
{
new_res_date += '<div class="header-title-date"><div class="header-title-date-name">'+daily[j%7]+ '</div><div class="header-title-date-value">'+json[i].res_date+ '</div></div>';
new_res_time += '</div></div></div><div class="title-row-date"><div class="appointment-collection"><div class="appointment-collection-first"><div><a class="appointment-time" href="#">'+json[i].res_time+ '</a></div>';
//alert("third :" +i);
j++;
}
});
j=0;
new_res_date += '</div></div>' ;
new_res_time += '</div></div></div></div></div></div></div>' ;
$(new_res_time).appendTo(".title-row-collection");
$(new_res_date).appendTo(".header-title-collection");
});
}
and other page that read data from databse is here
table.php :
<?php
include 'configure.php';
$doc_id = $_GET["id"];
$qr = "SELECT `res_date`,`res_time` FROM `reserve_tbl` WHERE `doc_id` = '".$doc_id."'";
$res= mysql_query($qr);
$i=0;
while($row = mysql_fetch_array($res))
{
$res_arr[$i]["res_date"] = $row["res_date"];
$res_arr[$i]["res_time"] = $row["res_time"];
$i++;
}
header('Content-type: application/json');
echo json_encode($res_arr);
?>
and
profinf.php:
<?php
include 'configure.php';
$doc_id = $_GET["id"];
$qr = "SELECT * FROM `doc_tbl` WHERE `doc_id` = '".$doc_id."'";
$res= mysql_query($qr) or die("Error: " . mysql_error() . "<br />In Query: " . $qr);;
$i=0;
while($row = mysql_fetch_array($res))
{
$doc_arr[$i]["doc_name"] = $row["doc_name"];
$doc_arr[$i]["doc_family"] = $row["doc_family"];
$doc_arr[$i]["doc_grade"] = $row["doc_grade"];
$doc_arr[$i]["doc_specialy"]= $row["doc_specialy"];
$doc_arr[$i]["doc_adress"] = $row["doc_adress"];
$i++;
}
header('Content-type: application/json');
echo json_encode($doc_arr);
?>
finaly here is connection configure.php
<?php
$cfg_server = "localhost";
$cfg_database = "db_name";
$cfg_username = "root";
$cfg_password = "";
$conn = mysql_connect($cfg_server, $cfg_username, $cfg_password);
if($conn)
{
if (!mysql_select_db($cfg_database))
{
die('Could not select Database: '.mysql_error());
}
}
if (!$conn)
{
die('Could not connect to Database: '.mysql_error());
}
?>
anybody have same the problem before?i need to display date column group by weekly element that is not table, if i use table is easier? but i don't know how can display column weekly group in table!can i group by data by SQL query?
thanks.

mySql has a Week function.
if you change your query to :-
SELECT `res_date`,`res_time`, WEEK(res_date) AS `res_week` FROM `reserve_tbl` WHERE `doc_id` = '".$doc_id."'";
You will be able to use the res_week field to track each record by week number and therefore show previous and next weeks

Related

How to show message or data only one time while select multiple checkbox in jquery?

code:
<script>
$(document).ready(function(){
$(".choose").click(function(){
job_type = $(':checked').map(function() {
return this.value;
}).get().join(',');
category = $("#cat_gory").val();
$.ajax({
type:"POST",
data:{"job_type":job_type,"category":category},
url:"type-jobs.php",
success:function(data){
$(".success").html(data);
}
});
});
});
</script>
<input type="hidden" name="cat_gory" id="cat_gory" value="<?php echo $job_category; ?>" />
<p class="flchek">
<input type="checkbox" name="choosetype" value="freelance" class="choose" id="33r">
<label for="33r">Freelance</label>
</p>
<p class="ftchek">
<input type="checkbox" name="choosetype" value="full time" class="choose" id="dsf">
<label for="dsf">Full Time</label>
</p>
<p class="ischek">
<input type="checkbox" name="choosetype" value="internship" class="choose" id="sdd">
<label for="sdd">Internship</label>
</p>
<div class="success"></div>
type-jobs.php
<?php
include("config.php");
$job_category = mysqli_real_escape_string($con,$_POST['category']);
$job_type = mysqli_real_escape_string($con,$_POST['job_type']);
$tag = explode(",",$job_type);
foreach($tag as $type)
{
$sql_job = mysqli_query($con,"select p.job_title,c.state,c.city from company c inner join jobs p on p.company_name = c.company_name where p.category = '".$job_category."' and job_type='".$type."'");
$result_job = mysqli_num_rows($sql_job);
if($result_job > 0)
{
while($row_jobs = mysqli_fetch_array($sql_job))
{
echo '<h3>'.$row_jobs['job_title'].'</h3>';
}
}
else
{
echo '<p id="c_mm">record not found</p>';
}
}
?>
In this code I have multiple checkbox. Now, When I click on checkbox to get data through jquery/ajax it return data to me but the problem is if I click on freelance checkbox it show me record not found again when I click on full time then it showing record not found as well as jobs. Now, I want if data was not found in my database it will show single message to me and if data found then hide message and show database record. So, How can I do this? Please help me.
Thank You
NO need to explode the $jobtype Use 'jobtype IN('.$jobtype.') '
<?php
include("config.php");
$job_category = mysqli_real_escape_string($con,$_POST['category']);
$job_type = mysqli_real_escape_string($con,$_POST['job_type']);
$sql_job = mysqli_query($con,"select p.job_title,c.state,c.city from company c inner join jobs p on p.company_name = c.company_name where p.category = '".$job_category."' and job_type IN('".$jobtype."') ');
$count = mysqli_num_rows($sql_job);
$row_data = mysqli_fetch_array($chek_result);
if($count > 0){
foreach($row_data as $data){
$message = '<h3>'.$data['job_title'].'</h3>';
}
}else{
$message = "No Data found";
}
echo $message;exit;
?>
If you want to show record not found message only if you don't find any record then you can use a flag in php something like this:
<?php
include("config.php");
$job_category = mysqli_real_escape_string($con,$_POST['category']);
$job_type = mysqli_real_escape_string($con,$_POST['job_type']);
$found = 0;
$message = '';
$tag = explode(",",$job_type);
foreach($tag as $type)
{
$sql_job = mysqli_query($con,"select p.job_title,c.state,c.city from company c inner join jobs p on p.company_name = c.company_name where p.category = '".$job_category."' and job_type='".$type."'");
$result_job = mysqli_num_rows($sql_job);
if($result_job > 0)
{
$found = 1;
while($row_jobs = mysqli_fetch_array($sql_job))
{
$message .= '<h3>'.$row_jobs['job_title'].'</h3>';
}
}
}
if(found == 0) {
$message = '<p id="c_mm">record not found</p>';
}
echo message;
?>
Notice $found flag here in code. HTH.

PHP Get Data Attribute From HTML5

I've got some problem!
I want to show both news-evt and news-ntc content in my web page.
The JS can POST "news-evt, news-ntc", but the PHP cannot process with this result, how can I do? I am new of php and ajax... Thanks!
My Table:
**id** **category**
0 news-evt
1 news-ntc
My HTML:
<ul id="blog-filters">
<li data-vid="news-evt, news-ntc"><a>All</a></li>
<li data-vid="news-evt"><a>Event</a></li>
<li data-vid="news-ntc"><a>Notice</a></li>
</ul>
My JS:
$(document).ready(function() {
$(document).on('click', '#blog-filters li', function(){
var last_id = $(this).data("vid");
$.ajax(
{
url:"load_data.php",
method:"POST",
data:{last_id:last_id},
dataType:"text",
success:function(data) {
if(data !== '') {
$('.post-item').remove();
$('.btn-load-more').remove();
$('.blog-content-rows').append(data);
} else {
$('.btn-load-more a').html("No More...");
}},
});
});
});
My PHP:
if (isset($_POST['last_id'])){
require_once('datalogin.php');
$last_id = ($_POST['last_id']);
$showLimit = 3;
$output = '';
$id = '';
sleep(1);
$raw_results = mysql_query("SELECT * FROM article WHERE (category LIKE '%".$last_id."%') ORDER BY date DESC LIMIT ".$showLimit) or die(mysql_error());
if(mysql_num_rows($raw_results) > 0) {
while($results = mysql_fetch_array($raw_results)) {
$id = $results['id'];
$output .= 'Something Code...';
}
}
}
Solved: Simply change$last_id = $_POST['last_id'] to $last_id = explode(',',$_POST['last_id']) and then add foreach ($last_id as $item) {$raw_results = mysql_query............}
New Problem: But there is a Order problem...the foreach loop output 'evt' result first...
You can always use the echo of PHP.
<div class="blog-content-rows">
<?php
if (isset($_POST['last_id'])){
require_once('datalogin.php');
$last_id = ($_POST['last_id']);
$showLimit = 3;
$output = '';
$id = '';
sleep(1);
$raw_results = mysql_query("SELECT * FROM article WHERE (category LIKE '%".$last_id."%') ORDER BY date DESC LIMIT ".$showLimit) or die(mysql_error());
if(mysql_num_rows($raw_results) > 0) {
while($results = mysql_fetch_array($raw_results)) {
$id = $results['id'];
$output .= 'Something Code...';
//new code here:
echo "<div>ID: ". $id ."<br/> Output: ". $output ."</div>";
}
}
}
?>
</div>
The result would be like:
<div class="blog-content-rows">
<div>ID: 1<br/> Output: Some_text</div>
<div>ID: 2<br/> Output: Some_other_text</div>
<div>ID: 3<br/> Output: Another_text</div>
</div>
Feel free to ask for anything else.

Filtering a jQuery ListView using Checkbox

I have jQuery ListView that loads data from a php file. I also have a checkbox that onclick should be able to filter the list. The filtering is done by sending a post message to server and refreshing the list. However, the checkbox list is not filtering the list. The code below is only part of the whole implementation. Here is the page:
http://i.cs.hku.hk/~hsbashir/Project_Work/Listview/restaurant_list.html
This is the HTML implementation:
<head>
<script>
lastRecord=0;
function loadRest(){
$('#sample').html( 'hello' );
$.get(
"queryRestaurantsList.php?lastRecord="+lastRecord,
function( data ) {
$('#rest_mesgs').append( data )
.listview( 'refresh' );
}
);
}
</script>
</head>
<body onload="loadRest()">
<div data-demo-html="true">
<form>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Select your type of Restaurant:</legend>
<input type="checkbox" name="checkbox-h-2a" id="checkbox-h-2a" onchange="onfilter()" value="Vegetarian"/>
<label for="checkbox-h-2a">Vegetarian</label>
</fieldset>
</form>
</div>
<div data-demo-html="true">
<ul data-role="listview" data-theme="a" data-split-theme="b" data-split-icon="plus" data-inset="true" id="rest_mesgs">
<li data-role="list-divider">Restaurants</li>
</ul>
</div>
<script>
function onfilter(){
if($("#checkbox-h-2a").prop('checked')){
document.getElementById("hehe").innerHTML = "if condition is true";
var a = document.getElementById("checkbox-h-2a");
$.post("queryRestaurantsList.php",
{
filter0 : a.value;
},
function(data){
$('#rest_mesgs').append( data )
.listview( 'refresh' );
});
}
else {
document.getElementById("hehe").innerHTML = "not working";
}
}
</script>
</body>
This is php file:
mysql_connect($host,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
//Check if POST array is empty or not
if ($_POST == null){
$query = "SELECT Name,Short_Loc,Image_Link,Type FROM Restaurant_Info";
$result = mysql_query($query) or die( "Unable to execute query");
while ($row = mysql_fetch_array($result)){
print '<li>';
print '<a href="'.$row['Full_Link'].'">';
print '<img style="height:80px;" src="'.$row['Image_Link'].'">';
print '<h2 style="text-wrap : normal">'.$row['Name'].'</h2>';
print '<p id="type" class="ui-li-aside"><strong>'.$row['Type'].'</strong></p>';
print '<p>'.$row['Short_Loc'].'</p>';
print '</a>';
print '</li>';
}
}
else {
$value1 = $_POST[filter0];
$query0 = 'SELECT Name,Short_Loc,Image_Link FROM Restaurant_Info WHERE Type LIKE ';
$query0 = $query0.'"%'.$value1.'%"';
$result = mysql_query($query0) or die( "Unable to execute query");
$num_results = mysql_num_rows($result);
if ($num_results == 0){
print "Your criteria does not match any of the restaurants";
}
else{
while($row = mysql_fetch_array($result)) {
print '<li>';
print '<a href="'.$row['Full_Link'].'">';
print '<img style="height:80px;" src="'.$row['Image_Link'].'">';
print '<h2 style="text-wrap : normal">'.$row['Name'].'</h2>';
print '<p>'.$row['Short_Loc'].'</p>';
print '</a>';
print '</li>';
}
}
I can see 2 errors, but unfortunately I can't test them.
1 - This php part:
else {
$value1 = $_POST[filter0];
Should be replace with:
else {
$value1 = $_POST['filter0'];
Otherwise filter0 will be treated as a constant instead of a string.
2 - On your html, you did:
<input type="checkbox" name="checkbox-h-2a" id="checkbox-h-2a" onchange="onfilter()" value="Vegetarian"/>
This should be
<input type="checkbox" name="checkbox-h-2a" id="checkbox-h-2a" onclick="onfilter()" value="Vegetarian"/>
I think a checkbox won't fire onchange when you check or uncheck it.
1 . To maintain checkbox state change use jQuery.toggle(). It's the safest way.
$("#checkbox-h-2a").toggle(function(){
var filter = $(this).val();
getListviewItems({filter0: filter});
}, function() {
getListviewItems();
});
2 . Make one function with params for getting list items. That way you'll keep your code clean and easy to maintain.
function getListviewItems(opt) {
opt.filter0 = (opt.filter0 == undefined)?'':opt.filter0;
/* Body of function, post and/or get calls, etc. */
}

PHP Search: Using Jquery to alter a php a value

I have a comics website. A feature it has is to allow users to search comics... the search will instantly parse the input and return thumbnail results based on matching title and keywords.
Originally, the search would return all of the results, and the bounding search box would expand infinitely downward, holding every single comic result. I thought it may be a nice touch to limit the results to 4, and display a message like "load 5 remaining images" if the user chooses to do so.
If they click on that message, I wanted limiting php variable to be removed or changed.
So far, it loads with the limit, and shows a link...
EDIT: Latest Code:
search_field.php (the search file that get's included on a page... this file calls search.php via JQuery):
<?php $site = (isset($_GET['site']) ? ($_GET['site']) : null); ?>
<div id="sidebar" class="searchborder">
<!--Allow users to search for comic-->
<!--<span class="search">Search for <?php// echo (($site == "artwork") ? 'artwork' : 'a comic'); ?> </span>-->
<script type="text/javascript">
function GetSearch(mySearchString){
$.get("./scripts/search.php", {_input : mySearchString, _site : '<?php echo $site ?>'},
function(returned_data) {
$("#output").html(returned_data);
}
);
}
</script>
<center>
<table>
<tr>
<td>
<span class="search">
<img src="./images/SiteDesign/Search.png" />
<input type="text" onkeyup="GetSearch(this.value)" name="input" value="" />
<!--<input id="site" type="hidden" value="<?php// echo $site; ?>">-->
</span>
</td>
</tr>
</table>
</center>
<span id="output"> </span>
</div>
search.php, the file that's called to parse the string and return the results:
<?php
//Query all images:
include 'dbconnect.php';
$site = $_GET['_site'];
$input = (isset($_GET['_input']) ? ($_GET['_input']) : 0);
$siteChoice = (isset($_GET['_choice']) ? ($_GET['_choice']) : $site);
$start = (isset($_GET['_start']) ? ($_GET['_start']) : null);
echo "start: " . $start;
//if user goes to hittingtreeswithsticks.com... no "site" value will be set... so I need to set one
if ($site == null) {
$site = "comics";
}
if ($siteChoice == "artwork") {
$sql = "SELECT id, title, keywords, thumb FROM artwork";
$thumbpath = "./images/Artwork/ArtThumbnails/";
}
else if ($siteChoice == "comics") {
$sql = "SELECT id, title, keywords, thumb FROM comics";
$thumbpath = "./images/Comics/ComicThumbnails/";
}
else {
$sql = "SELECT id, title, keywords, thumb FROM $site";
if ($site == "artwork") {
$thumbpath = "./images/Artwork/ArtThumbnails/";
}
else {
$thumbpath = "./images/Comics/ComicThumbnails/";
}
}
/* For this to work, need all comics replicated in an "All Comics" file along with "All Thumbnails"
else {
$sql = "SELECT id, title, thumb FROM comics
UNION
SELECT id, title, thumb FROM artwork";
$thumbpath = "./images/AllThumbnails/";
}*/
$imgpaths = $mysqli->query($sql);
mysqli_close($mysqli);
$idresult = array();
$imgresult = array();
$thumbresult = array();
//CHECK IF $INPUT == IMAGE PATH
if (strlen($input) > 0)
{
while ($row = $imgpaths->fetch_assoc())
{
//query against key words, not the image title (no one will remember the title)
if (stripos($row['keywords'], $input) !== false || strtolower($input)==strtolower(substr($row['title'],0,strlen($input))))
//if (strtolower($input)==strtolower(substr($row['title'],0,strlen($input))))
{
array_push($idresult, $row['id']);
array_push($imgresult, $row['title']);
array_push($thumbresult, $row['thumb']);
}
}
//ECHO RESULTS ARRAY
if(count($imgresult) == 0)
{
echo "<p>no suggestions</p>";
}
else
{
echo "<ul>";
$k = 0;
$max = 4;
if (count($imgresult) > $max) {
while ($k < count($imgresult) && $k < $max)
{
echo '<li>
<span class="sidebarimages"><a href=".?action=viewimage&site=' . $siteChoice . '&id=' . $idresult[$k] . '">
<img src="./scripts/thumber.php?img=.'.$thumbpath.$thumbresult[$k].'&mw=90&mh=90"/></a></span>
</li>';
$k++;
}
$difference = count($imgresult)-$k;
echo "<br/><i><a href='.?action=homepage&site=" . $siteChoice . "&start=4' class='loadSearch'>load " . $difference . " more result" . (($difference != 1) ? 's' : '') . "... </a></i>";
}
else {
while ($k < count($imgresult))
{
echo '<li>
<span class="sidebarimages"><a href=".?action=viewimage&site=' . $siteChoice . '&id=' . $idresult[$k] . '">
<img src="./scripts/thumber.php?img=.'.$thumbpath.$thumbresult[$k].'&mw=90&mh=90"/></a></span>
</li>';
$k++;
}
}
echo "</ul>";
}
}
?>
<script type="text/javascript">
$(".loadSearch").click(function() {
//alert("Test");
$.get("./search.php", {_start : 4},
function (returned_data) {
$("#moreResults").html(returned_data);
}
);
});
</script>
Try this:
<script type="text/javascript">
$("#loadSearch").click(function() {
$.get('URL WITH QUERY', function(data) {
$('#results').html(data);
});
});
</script>
From what i get all you need is when "load more" is clicked only new results should be shown.
Load more has to be a url same as your search url.
Search/Autocomplete URL - example.com/autocomplete?q=xkd
Load More URL - example.com/autocomplete?q=xkd&start=4&max=1000
Just add two parameters to your url. start and max. Pass them to your queries and you get exact result.
Only verify Start < Max and are integers intval() and not 0 empty(). Also if Max <= 4 then dont show load more.
I would give all of your results back, then try to determine your results. If more then 4, loop out the first 4 results. If the user clicks on the load more button your start looping from your 4th element. That way you only need to hit the server once (per search).
Try to give back your results in json, so you can format it the way you like in your html file.
In pseudo code:
searchTerm = 'hello';
resultsFromServer = getResults($searchterm);
resultcounter = count(resultsFromServer);
if(resultcounter > 4)
loop 4 results
else
loop all results
$(".loadSearch").click(function(e) {
//alert("Test");
e.preventDefault();
$.get("./search.php", {_start : 4},
function (returned_data) {
$("#moreResults").html(returned_data);
}
);
I ended up going with jquery show and hide functions.
PHP Snippet:
//ECHO RESULTS ARRAY
if(count($imgresult) == 0)
{
echo "<p>no suggestions</p>";
}
else
{
echo "<ul>";
$k = 0;
$max = 4;
while ($k < count($imgresult) && $k < $max)
{
echo '<li>
<span class="sidebarimages"><a href=".?action=viewimage&site=' . $siteChoice . '&id=' . $idresult[$k] . '">
<img src="./scripts/thumber.php?img=.'.$thumbpath.$thumbresult[$k].'&mw=90&mh=90"/></a></span>
</li>';
$k++;
}
$difference = count($imgresult)-$k;
echo '<div id="moreResults">';
while ($k < count($imgresult))
{
echo '<li>
<span class="sidebarimages"><a href=".?action=viewimage&site=' . $siteChoice . '&id=' . $idresult[$k] . '">
<img src="./scripts/thumber.php?img=.'.$thumbpath.$thumbresult[$k].'&mw=90&mh=90"/></a></span>
</li>';
$k++;
}
echo '</div>';
if (count($imgresult) > $max) {
?>
<br />Load <?php echo $difference; ?> more result<?php echo (($difference != 1) ? 's' : ''); ?>...
<?php
}
echo "</ul>";
}
}
Jquery:
<script type="text/javascript">
$("#moreResults").hide();
$("#showMore").click(function() {
$("#moreResults").show();
$("#showMore").hide();
});

Using jQuery to load a PHP Page in a div

I have this script:
<script type='text/javascript' src='js/jquery-1.4.4.mi.js'></script>
<script type='text/javascript'>
$('.filterMonth').change(function(){
alert('ijijiji');
$.ajax({
url: 'ajax/filterMandays.php',
//type: 'GET',
success: function(data){
//data is returned back
$('#mandayTable').html(data);
}
});
});
</script>
and this html:
<select name ="filterMonth">
<?php
$array_month = array("January","February","March","April","May","June","July","August","September","October","November","December");
foreach($array_month as $key => $month)
{
$value_month = $key+1;
echo "<option value = '$value_month'>$month</option>";
}
?>
</select>
-
<select name = "filterYear" onChange = "filter(filterMonth.value, filterYear.value)">
<?php
$curYear = date('Y');
for($i = 1990; $i<=$curYear+10; $i++)
{
if($i == $curYear)
{
echo "<option value = '$i' selected = 'selected'>$i</option>";
}
else
{
echo "<option value = '$i'>$i</option>";
}
}
?>
</select>
</td>
</tr>
</br>
</br>
<tr>
<div id="mandayTable"></div>
and this php page:
<?php
include("all.php");
$q = "SELECT md.mandays_id,md.employeenum,md.month,md.year,md.required_man_days,d.firstname,d.lastname
FROM tbl_mandays md,tbl_employee_details d
WHERE md.active = '1'
AND md.employeenum = d.employeenum
AND md.month = '10';";
$res = $db->Execute($q);
echo "<table border = 1>";
echo "<tr><th>Employee Number</th><th>First Name</th><th>Last Name</th><th>Month-Year</th><th>Required Man Days</th><th>Edit/Delete</th></tr>";
while($rows = $res->FetchRow())
//for($i=0;$i<5;$i++)
{
//iterating through // check if employee
// // if(isset($row[])) { }
$mandays_id = $rows[0];
$empnum = $rows[1];
$month_year = $rows[2] ."-" .$rows[3];
$required_man_days = $rows[4];
$firstname = $rows['month'];
$lastname = $rows[6];
//echo approvers here are not taken
//<a href=\"view_team.php?id=".$empnum."\" -> for someone to view the people beneath them (like org tree)
echo "<tr><td>".$empnum . "</td><td>".$firstname ."</td><td>".$lastname ."</td><td>" . $month_year ."</td><td>" .$required_man_days . "</td><td width = \"200\" align = \"center\"><a href = 'edit_mandays.php?mandays_id=$mandays_id');'>Edit/Delete</a></td></tr>";
}
echo "</table>";
?>
the script should basically load the php page in the div in the html once the "filterMonth" has been changed. but it doesn't work.
what seems to be the problem? :(
The selector in your jQuery is $('.filterMonth') but your select box doesn't have the filterMonth class. You need to change it to $('select[name=filterMonth]').
In order for the jQuery selector to contain your select, you need to make sure that it runs after the Select element is in the DOM (ie: lower down the HTML), or run your JavaScript once the document has finished loading, for example:
<script type='text/javascript' src='js/jquery-1.4.4.mi.js'></script>
<script type='text/javascript'>
jQuery(function() {
// do your DOM selections here, this function only runs once the document is loaded
});
</script>

Categories