本文介绍了想将结果从javascript文件存储到php mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Hello Everyone, 我想将结果从js文件存储到mysql数据库请帮忙。 javascript代码如下: function EmailResults(strAddress) { if (!g_oQuizResults.strTitle) { g_oQuizResults.strTitle = ; } var g_strSubject = 测验结果: + g_oQuizResults.strTitle; var strQuizResults = ; var strMainHeader = + g_oQuizResults.strTitle + \ nStatus,原始分数,通过分数,最高分数,最低分数,时间数量N; var strLineHeader = \ nn \\ nDate,时间,分数,交互ID,目标ID,交互类型,学生响应,结果,权重,延迟\ n; var strMainData = \ n ; var strLineData = \ n ; // 状态 strMainData + = g_oQuizResults.strResult + ,; // 得分 // strMainData + = g_oQuizResults.strScore +,; // 原始分数 strMainData + = g_oQuizResults.strPtScore + ,; // 传递分数 strMainData + = 数学 .round((g_oQuizResults.strPassingScore / 100)* g_oQuizResults.strPtMax)+ ; // 最高得分 strMainData + = g_oQuizResults.strPtMax + ,; // 最低分 strMainData + = 0 + ,; // 时间 strMainData + = GetTime(g_oQuizResults。 dtmFinished); for ( var i = 0 ; i< g_arrResults.length; i ++) { // 日期 strLineData + = GetDate(g_arrResults [i] .dtmFinished)+ , ; // 时间 strLineData + = GetTime(g_arrResults [ i] .dtmFinished)+ ,; // 得分 strLineData + = g_arrResults [i] .nPoints + ,; // 交互ID strLineData + = g_arrResults [i ] .strInteractionId + ,; // 目标ID strLineData + = g_arrResults [i ] .strObjectiveId + ,; // 交互类型 strLineData + = g_arrResults [i ] .strType + ,; // 学生回复 var strResponse = g_arrResults [i] .strStudentResponse; strResponse = ReplaceAll(strResponse, ', %27); strLineData + = strResponse + ,; // 结果 strLineData + = g_arrResults [i] .strResult + ,; // 权重 strLineData + = 1,; // 延迟 strLineData + = g_arrResults [i] .strLatency; strLineData + = \ n; } strQuizResults = strMainHeader + strMainData + strLineHeader + strLineData; var sHTML = ; sHTML + = ' < FORM id =formQuizmethod =POSTaction =mailto: ' + strAddress + ' ?subject =' + g_strSubject + ' enctype =text / plain>'; sHTML + = ' < INPUT TYPE =hiddenNAME =Quiz ResultsVALUE = \ '' + strQuizResults + ' \'>'; sHTML + = ' < br>< input type =submit>< br> ; sHTML + = ' < / FORM>'; document .getElementById( divEmail).innerHTML = sHTML; document .getElementById( formQuiz)提交(); } 解决方案 你的问题的答案是PHP,也许是AJAX(通常从一个开始javaScript)。 PHP运行服务器端并具有访问MySQL的功能。 http://www.w3schools.com/php/default.asp [ ^ ] Hello Everyone,I want to store the result from js file to mysql database please help.The javascript code is below:function EmailResults(strAddress){if (!g_oQuizResults.strTitle){g_oQuizResults.strTitle = "";}var g_strSubject = "Quiz Results: " + g_oQuizResults.strTitle;var strQuizResults = "";var strMainHeader = " " + g_oQuizResults.strTitle + "\nStatus, Raw Score, Passing Score, Max Score, Min Score, Time\n";var strLineHeader = "\n\nDate, Time, Score, Interaction ID, Objective Id, Interaction Type, Student Response, Result, Weight, Latency\n";var strMainData = "\n";var strLineData = "\n";// StatusstrMainData += g_oQuizResults.strResult + ",";// Score// strMainData += g_oQuizResults.strScore + ",";// Raw ScorestrMainData += g_oQuizResults.strPtScore + ",";// Passing ScorestrMainData += Math.round((g_oQuizResults.strPassingScore/100) * g_oQuizResults.strPtMax) + ",";// Max ScorestrMainData += g_oQuizResults.strPtMax + ",";// Min ScorestrMainData += 0 + ",";// TimestrMainData += GetTime(g_oQuizResults.dtmFinished);for (var i = 0; i < g_arrResults.length; i++){//DatestrLineData += GetDate(g_arrResults[i].dtmFinished) + ",";// TimestrLineData += GetTime(g_arrResults[i].dtmFinished) + ",";// ScorestrLineData += g_arrResults[i].nPoints + ",";// Interaction IdstrLineData += g_arrResults[i].strInteractionId + ",";// Objective IdstrLineData += g_arrResults[i].strObjectiveId + ",";// Interaction TypestrLineData += g_arrResults[i].strType + ",";// Student Responsevar strResponse = g_arrResults[i].strStudentResponse;strResponse = ReplaceAll(strResponse, "'", "%27");strLineData += strResponse + ",";// ResultstrLineData += g_arrResults[i].strResult + ",";// WeightstrLineData += "1,";// LatencystrLineData += g_arrResults[i].strLatency;strLineData += "\n";}strQuizResults = strMainHeader + strMainData + strLineHeader + strLineData;var sHTML = "";sHTML += '<FORM id="formQuiz" method="POST" action="mailto:' + strAddress + '?subject=' + g_strSubject + '" enctype="text/plain">';sHTML += '<INPUT TYPE="hidden" NAME="Quiz Results" VALUE=\'' + strQuizResults + '\'>';sHTML += '<br><input type="submit"><br>';sHTML += '</FORM>';document.getElementById("divEmail").innerHTML = sHTML;document.getElementById("formQuiz").submit();} 解决方案 The answer to your question is PHP, and perhaps, AJAX as well (which often starts from within a javaScript).PHP runs server-side and has functionality to access MySQL.http://www.w3schools.com/php/default.asp[^] 这篇关于想将结果从javascript文件存储到php mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-22 02:48