用戶選擇日期,月份和年份,然後按一個按鈕以顯示基於他選擇的日期的數據庫值 我不知道代碼中的問題在哪裏php基於onclick函數的輸入類型日期
<style>
.button {border-radius: 8px;}
.button1 {font-size: 20px;}
</style>
<form>
إختر التاريخ : <input type="date" name="bday" id="dat"><br>
<button type=button class="button button1" onclick="document.getElementById('data').innerHTML = myFunction(document.getElementById('dat').value)">إظهار الإستهلاك اليومي</button>
<hr>
<span id="data" ></span>
</form>
<script>// <![CDATA[
function myFunction($x) {
$current_user=get_current_user_id();// to fetch the right data for the right user
// ياخذ اليوم والشهر والسنه الي اختارها اليوزر
global $wpdb;
$d=date('j');//define variable to store the day
$m=date('m');//define variable to store the month
$y=date('Y');//define variable to store the year
$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
我覺得你是如此的困惑PHP(服務器端腳本)和JavaScript(客戶端腳本)也許研究一些PHP - JS - 阿賈克斯 –
在您的查詢,'天= d',應該是'天= $ d' –
我使用WordPress – user6159635