$('.delete').click(function() {
$('.pop-up-alert').addClass('clicked');
function() {
if ($('.no-btn').click()) {
$('.pop-up-alert').removeClass('clicked');
} else if ($('.yes-btn').click()) {
$(.delete).parent().remove();
} else {
$('.pop-up-alert').removeClass('clicked');
};
};
});
我需要在其他地方回显$ ActiveWeekEndingDate,如何在函数外部正确访问它。
编辑:
我设法让它与以下人员合作但是准备声明是不是真的必要呢?
function GetActiveWeek($mysqli, $ActiveWeekEndingDate) {
$stmt = "SELECT ParameterValue FROM INF_WebConfig WHERE ParameterName = 'ActiveWeekEndingDate'";
$ActiveWeekEndingDate = $mysqli->query($stmt);
return $ActiveWeekEndingDate;
}
答案 0 :(得分:0)
为什么不在回复中处理它?</ p>
$ActiveWeekEndingDate = GetActiveWeek();
echo $ActiveWeekEndingDate;
如果你坚持让它全球化(不鼓励),请在函数上面添加:
global $ActiveWeekEndingDate;
答案 1 :(得分:0)
您需要将GetActiveWeek函数的返回值分配给您可以从函数中访问的变量。
function GetActiveWeek($mysqli, $ActiveWeekEndingDate) {
$stmt = "SELECT ParameterValue FROM INF_WebConfig WHERE ParameterName = 'ActiveWeekEndingDate'";
$ActiveWeekEndingDate = $mysqli->query($stmt);
return $ActiveWeekEndingDate;
}
$retVal = GetActiveWeek($mysqli, $ActiveWeekEndingDate);
答案 2 :(得分:-1)
function GetActiveWeek($mysqli) {
$stmt = $mysqli->prepare("SELECT ParameterValue FROM INF_WebConfig WHERE ParameterName = 'ActiveWeekEndingDate'");
$stmt->execute();
$stmt -> bind_result($ActiveWeekEndingDate);
$stmt -> fetch();
$stmt -> close();
$mysqli -> close();
return $ActiveWeekEndingDate;
}
这就是我取得成果的方式。我只是调用初始化变量的函数。