>用户输入日期,月份和年份,然后按一个按钮根据他选择的日期向他显示数据库的值,但我不知道如何在$d,$m和$y变量中保存日期,月份和年份
<style>
.button {border-radius: 8px;}
.button1 {font-size: 20px;}
</style>
<form>
اليوم : <input id="txtDay" type="text" placeholder="DD" />
الشهر : <input id="txtMonth" type="text" placeholder="MM" />
السنة : <input id="txtYear" type="text" placeholder="YYYY" />
<button id="but" onclick="daily()">إظهار الإستهلاك اليومي</button>
</form>
<script>// <![CDATA[
// to show the right value from database
function daily() {
$current_user=get_current_user_id();// to fetch the right data for the right user
// takes the values entered by the user
global $wpdb;
$d=???????????//define variable to store the day enter by user
$m=???????????//define variable to store the month enter by user
$y=???????????//define variable to store the year enter by user
$daily_amount= $wpdb->get_var("SELECT daily_amount FROM arduino_period_use where ID=$current_user and day=$d and month=$m and year=$y ");
print_r($daily_amount);
}
// ]]></script
添加名称至
<input id="txtDay" type="text" placeholder="DD" />
例如:
<input name="txtDay" id="txtDay" type="text" placeholder="DD" />
然后,您可以将其用作$_POST['txtDay']
或者,当您想将其用作$d
时,您可以编写$d = $_POST['txtDay']
.
万一您通过 POST 发送表单数据!我希望你发布的PHP代码在服务器端。