|
在投票結果顯示頁面的製作中提到要繫結兩個資料集 voteSummary 和 RecVoteShow 並新增一個變數 voteSUM 接收 voteSummary 的voteSUM 的數值。書中提到要先做voteSummary 後作 RecVoteShow以免無法接受數值而產生錯誤。我照步驟做但是還是出現以下錯誤訊息: MySQL Error#: 1054
Unknown column 'voteSUM' in 'field list'
可協助判斷是哪裡出了問題嗎,我將兩個資料集的程式碼張貼在下:
$sendID_VoteSummary = "1"; if (isset($HTTP_GET_VARS['vote_id'])) { $sendID_VoteSummary = $HTTP_GET_VARS['vote_id']; } mysql_select_db($database_connVote, $connVote); $query_VoteSummary = sprintf("SELECT SUM(voteitem.vote_count) AS voteSUM, MAX(voteitem.vote_count) AS voteMAX FROM voteitem Where voteitem.vote_id = %s", GetSQLValueString($sendID_VoteSummary, "int")); $VoteSummary = mysql_query($query_VoteSummary, $connVote) or die(mysql_error()); $row_VoteSummary = mysql_fetch_assoc($VoteSummary); $totalRows_VoteSummary = mysql_num_rows($VoteSummary);
$voteSUM_RecVoteShow = "1"; if (isset($row_VoteSummary['voteSUM'])) { $voteSUM_RecVoteShow = $row_VoteSummary['voteSUM']; } $sendID_RecVoteShow = "1"; if (isset($HTTP_GET_VARS['vote_id'])) { $sendID_RecVoteShow = $HTTP_GET_VARS['vote_id']; } mysql_select_db($database_connVote, $connVote); $query_RecVoteShow = sprintf("SELECT votemain.vote_id, votemain.vote_name, voteitem.voteitem_id, voteitem.vote_item, voteitem.vote_count, voteitem.vote_count/%s FROM votemain INNER JOIN voteitem ON votemain.vote_id = voteitem.vote_id WHERE votemain.vote_id = %s ", GetSQLValueString($voteSUM_RecVoteShow, "int"),GetSQLValueString($sendID_RecVoteShow, "int")); $RecVoteShow = mysql_query($query_RecVoteShow, $connVote) or die(mysql_error()); $row_RecVoteShow = mysql_fetch_assoc($RecVoteShow); $totalRows_RecVoteShow = mysql_num_rows($RecVoteShow); |