从JavaScript函数调用PHP

时间:2018-10-17 08:34:04

标签: javascript php

我有一个下拉菜单,用户可以在其中选择周数。如果数据库中未显示所选的星期,则必须显示“未完成”,如果存在所选的星期,则必须显示“完成”

//JavaScript function

function onchangeval(){

}  

//PHP 

<?php

$date_string = date('Y-m-d');

if(!isset($_GET['week'])) {
$_GET['week'] = $currentweekno;
}

$sql   = "SELECT distinct Import as Import FROM info_table where Import = '".$date_string."' and Week(Import) <= '".$currentweekno."' ";

//$currentweekno is the user modified CW from the drop down (dynamic - am not sure)

$adddetails = mysql_query($sql);
$adddetails = mysql_fetch_assoc($adddetails);

if ($adddetails['Import'] != ''){
    $title1="Done";
}else if ($adddetails['Import'] == ''){
    $title1="Not Done";
}

?>

<td>
 CW:
 <select name="week" id="week" style="width: 100px" onchange="return onchangeval(); >
 <option value="">--Select--</option>
 <?php for($i=1;$i<=53;$i++) {?>
 <option value="<?php echo $i;?>"  <?php echo @$_GET['week'] == $i ? "selected" : "";?> ><?php echo $i;?></option>
 <?php }?>
 <option value="1">1</option>
 </select>
</td>

<td>    
<span class='u' style='color: red'><b><?php echo $title1;?></b></span>
</td>

这时我感到震惊,有人可以在这里指导我如何做

0 个答案:

没有答案