2

我有一个用于获取伊斯兰月份的 javascript 文件。我使用 javascript 从 sql 获取整个当月的数据。我想仅在当天使用相同的 javascript 从 mysql 获取数据。请帮助我只是想不通。来源粘贴在下面:

:: javascript ::

function gmod(n,m){
    return ((n%m)+m)%m;
}

function kuwaiticalendar(adjust){
    var today = new Date();
    if(adjust) {
        adjustmili = 1000*60*60*24*adjust; 
        todaymili = today.getTime()+adjustmili;
        today = new Date(todaymili);
    }
    day = today.getDate();
    month = today.getMonth();
    year = today.getFullYear();
    m = month+1;
    y = year;
    if(m<3) {
        y -= 1;
        m += 12;
    }

    a = Math.floor(y/100.);
    b = 2-a+Math.floor(a/4.);
    if(y<1583) b = 0;
    if(y==1582) {
        if(m>10)  b = -10;
        if(m==10) {
            b = 0;
            if(day>4) b = -10;
        }
    }

    jd = Math.floor(365.25*(y+4716))+Math.floor(30.6001*(m+1))+day+b-1524;

    b = 0;
    if(jd>2299160){
        a = Math.floor((jd-1867216.25)/36524.25);
        b = 1+a-Math.floor(a/4.);
    }
    bb = jd+b+1524;
    cc = Math.floor((bb-122.1)/365.25);
    dd = Math.floor(365.25*cc);
    ee = Math.floor((bb-dd)/30.6001);
    day =(bb-dd)-Math.floor(30.6001*ee);
    month = ee-1;
    if(ee>13) {
        cc += 1;
        month = ee-13;
    }
    year = cc-4716;

    if(adjust) {
        wd = gmod(jd+1-adjust,7)+1;
    } else {
        wd = gmod(jd+1,7)+1;
    }

    iyear = 10631./30.;
    epochastro = 1948084;
    epochcivil = 1948085;

    shift1 = 8.01/60.;

    z = jd-epochastro;
    cyc = Math.floor(z/10631.);
    z = z-10631*cyc;
    j = Math.floor((z-shift1)/iyear);
    iy = 30*cyc+j;
    z = z-Math.floor(j*iyear+shift1);
    im = Math.floor((z+28.5001)/29.5);
    if(im==13) im = 12;
    id = z-Math.floor(29.5001*im-29);

    var myRes = new Array(8);

    myRes[0] = day; //calculated day (CE)
    myRes[1] = month-1; //calculated month (CE)
    myRes[2] = year; //calculated year (CE)
    myRes[3] = jd-1; //julian day number
    myRes[4] = wd-1; //weekday number
    myRes[5] = id; //islamic date
    myRes[6] = im-1; //islamic month
    myRes[7] = iy; //islamic year

    return myRes;
}
function writeIslamicDate(adjustment) {
    var wdNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    var iMonthNames = new Array("Muharram-ul-Haram","Safar-ul-Muzaffar","Rabi-ul-Awwal","Rabi-us-Sani","Jumad-al-Awwal","Jumad-as-Sani","Rajab-ul-Murajjab","Shaban-ul-Muazzam","Ramadan-ul-Mubarak","Shawwal-ul-Mukarram","Zeeqada-tul-Haram","Zulhijja-tul-Haram");
    var iDate = kuwaiticalendar(adjustment);
    var outputIslamicDate = wdNames[iDate[4]] + ", " 
    + iDate[5] + " " + iMonthNames[iDate[6]] + " " + iDate[7] + " AH";
    return outputIslamicDate;
}

function writeIslamicMonthID(adjustment) {
    var iMonthNames = new Array("1","2","3","4","5","6","7","8","9","10","11","12");
    var iDate = kuwaiticalendar(adjustment);
    var outputIslamicDate = iMonthNames[iDate[6]];
    return outputIslamicDate;
}

:: PHP ::

<?php $current_month_id = $_GET["current-month-id"]; ?>
<?php $current_idate_id = $_GET["current-idate-id"]; ?>


   <?php
header('Content-Type: text/html; charset=utf-8');
    $con=mysqli_connect("localhost","root","","");
mysqli_set_charset($con,'utf8');
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }

    $display = mysqli_query($con,"SELECT * FROM table WHERE month ='$current_month_id' AND day ='$current_idate_id' ");



echo "<marquee id=marMessages dir=rtl onmouseover=this.scrollAmount=0 onmouseout=this.scrollAmount=2 scrollAmount=2 direction=up width='95%' height='112'>
<p align='Left'>

";

 while($row = mysqli_fetch_array($display))
      {

    echo "<div>";
    echo "<ul class='arr-three-list'>";
    echo "<li>";    
    echo "{$row['n_namest']}";
    echo "</li></ul></div> <br>";

      }

echo "</p></marquee>";


    mysqli_close($con);
    ?>
4

1 回答 1

0

正确答案如下:

function gmod(n,m){
    return ((n%m)+m)%m;
}

function kuwaiticalendar(adjust){
    var today = new Date();
    if(adjust) {
        adjustmili = 1000*60*60*24*adjust; 
        todaymili = today.getTime()+adjustmili;
        today = new Date(todaymili);
    }
    day = today.getDate();
    month = today.getMonth();
    year = today.getFullYear();
    m = month+1;
    y = year;
    if(m<3) {
        y -= 1;
        m += 12;
    }

    a = Math.floor(y/100.);
    b = 2-a+Math.floor(a/4.);
    if(y<1583) b = 0;
    if(y==1582) {
        if(m>10)  b = -10;
        if(m==10) {
            b = 0;
            if(day>4) b = -10;
        }
    }

    jd = Math.floor(365.25*(y+4716))+Math.floor(30.6001*(m+1))+day+b-1524;

    b = 0;
    if(jd>2299160){
        a = Math.floor((jd-1867216.25)/36524.25);
        b = 1+a-Math.floor(a/4.);
    }
    bb = jd+b+1524;
    cc = Math.floor((bb-122.1)/365.25);
    dd = Math.floor(365.25*cc);
    ee = Math.floor((bb-dd)/30.6001);
    day =(bb-dd)-Math.floor(30.6001*ee);
    month = ee-1;
    if(ee>13) {
        cc += 1;
        month = ee-13;
    }
    year = cc-4716;

    if(adjust) {
        wd = gmod(jd+1-adjust,7)+1;
    } else {
        wd = gmod(jd+1,7)+1;
    }

    iyear = 10631./30.;
    epochastro = 1948084;
    epochcivil = 1948085;

    shift1 = 8.01/60.;

    z = jd-epochastro;
    cyc = Math.floor(z/10631.);
    z = z-10631*cyc;
    j = Math.floor((z-shift1)/iyear);
    iy = 30*cyc+j;
    z = z-Math.floor(j*iyear+shift1);
    im = Math.floor((z+28.5001)/29.5);
    if(im==13) im = 12;
    id = z-Math.floor(29.5001*im-29);

    var myRes = new Array(8);

    myRes[0] = day; //calculated day (CE)
    myRes[1] = month-1; //calculated month (CE)
    myRes[2] = year; //calculated year (CE)
    myRes[3] = jd-1; //julian day number
    myRes[4] = wd-1; //weekday number
    myRes[5] = id; //islamic date
    myRes[6] = im-1; //islamic month
    myRes[7] = iy; //islamic year

    return myRes;
}

//COMPLETE DATE
function writeIslamicDate(adjustment) {
    var wdNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    var iMonthNames = new Array("Muharram-ul-Haram","Safar-ul-Muzaffar","Rabi-ul-Awwal","Rabi-us-Sani","Jumad-al-Awwal","Jumad-as-Sani","Rajab-ul-Murajjab","Shaban-ul-Muazzam","Ramadan-ul-Mubarak","Shawwal-ul-Mukarram","Zeeqada-tul-Haram","Zulhijja-tul-Haram");
    var eMonthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
    var iDate = kuwaiticalendar(adjustment);
    var outputIslamicDate = wdNames[iDate[4]] + ", " + iDate[5] + " " + iMonthNames[iDate[6]] + " " + iDate[7] + " AH";
    return outputIslamicDate;
}
//ONLY MONTH
function writeIslamicMonthID(adjustment) {
    var iMonthNames = new Array("1","2","3","4","5","6","7","8","9","10","11","12");
    var iDate = kuwaiticalendar(adjustment);
    var outputIslamicMonth = iMonthNames[iDate[6]];
    return outputIslamicMonth;
}
//ONLY DATE
function writeIslamicDayID(adjustment) {
    var iMonthNames = new Array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30");
    var iDate = kuwaiticalendar(adjustment);
    var outputIslamicDay = iDate[5];
    return outputIslamicDay;
}
于 2013-08-23T17:47:50.547 回答