標題可能看起來很模糊,對不起,我不知道如何說出我的問題。如何將HTML標記的類值傳遞給一個php變量
我試圖讓一個PHP變量被分配一個按鈕類的時候按下按鈕的值。有點像這樣:
<input id="button-id" class="button-1" type="button" onclick="<?php $variable=class of button-id; // Assign the variable here ?>"
顯然,語法錯了,因爲我不知道該怎麼做,或者它是否可能。
的原因,我需要的,這是因爲我在做一個MySQL查詢,這將依賴於$variable
像這樣:
$query = "SELECT * FROM table WHERE name='{$variable}'";
這需要像這樣由於什麼查詢被用於。
感謝您的任何幫助。
必須有一個更好的方法,但需要更多的內容,一個隱藏的表單域會想到 – 2013-07-09 23:57:33
你能回答我將如何做到這一點。 – RedJax
把id放在一個隱藏的表單域中,當按下按鈕時將會提交。 – 2013-07-10 00:00:17