我想在我的查詢的「having」子句中使用變量bradio,但我不知道如何獲取jquery變量的內容並將其傳遞到我的sql查詢中。這是我的PHP文件的一個片段。你能告訴我怎麼做到這一點?PHP的 - 如何將jQuery變量的內容傳遞到SQL查詢?
感謝
$conn = mysql_connect("localhost","form-test","pass");
$db = mysql_select_db("form-test",$conn);
?>
<script type="text/javascript">
jQuery.noConflict();
jQuery(function()
{
jQuery('#event_form_field-<?php echo $event_id; ?>').click(function()
{
var bradio= jQuery("input[type=radio]:checked").val()
alert(bradio); });});
</script>
<?php
$query2 = "SELECT COUNT(wp_events_answer.answer) as rep, wp_events_answer.attendee_id as idq, wp_events_question.quota as quota2, wp_events_attendee.event_id as ev, wp_events_answer.answer as answ, wp_events_question.id as qst3
FROM wp_events_answer, wp_events_attendee, wp_events_question
WHERE wp_events_answer.question_id = wp_events_question.id AND wp_events_answer.attendee_id = wp_events_attendee.id
HAVING answer =
GROUP BY answ;";
$result2 = mysql_query($query2) or die(mysql_error());
while($row2 = mysql_fetch_row($result2)) {
}
?>
你的混合服務器和客戶端...不會工作。 嘗試通過表單或Ajax將您的客戶端(JS)數據提交給服務器。 – helle 2011-12-21 10:07:16