开发者

how can i get news from jQuery datepicker calendar?

I made datepicker code, absolutely similar to http://jqueryui.com/demos/datepicker/#inline and i want to make news calendar:

JS side:

$(document).ready(function(){
   $("#datepicker").datepicker({
       onSelect: function(dateText, inst) {
           window.open("?action=news_archive&date=" + dateText + "&lang=<?=$lang?>"); 
        }
     }
);

});

PHP side:

$date = $_GET[ "date" ];
mysql_query(SELECT * FROM news WHERE date = $da开发者_如何转开发te);

but when i refresh page, i'm able to link all pages what i pressed, and if there is similarity, it retrieves news, if not the page is empty. i want to filter and make url only if there is a record and this record is similar to my date in mysql database.

the url's i have:

index.php?action=news_archive&date=2011-07-07&lang=eng

index.php?action=news_archive&date=2011-07-08&lang=eng

index.php?action=news_archive&date=2011-07-09&lang=eng

and so on...

but i don't have news linked on 2011-07-08 and 2011-07-09 in my mysql database, so i don't want to be linked 08 and 09 on my calendar.

sorry for my bed english and thanks in advance.


You will first need to bring a list of the dates from the db where there are news, and use that list to disable the calendar dates using the beforeShowDay event of the datepicker..

$('.selector').datepicker({
   beforeShowDay: function(date) {
     // check if date is in the list and if so return [true]
     // or [false] if the date is not active..
   },
   onSelect: function(dateText, inst) {
       window.open("?action=news_archive&date=" + dateText + "&lang=<?=$lang?>"); 
   }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜