0
您好,我目前正在为我的学位项目构建一个粗略的原型,并且我在上周遇到了一些问题。基本上我有一个测试人员记录防病毒软件测试结果的系统。我已经填充了父表中记录的下拉列表,现在我想捕获用户选择的值和用户标识,并将其输入到链接表中以记录此信息。但我只想捕获该测试的主键testID而不是测试的名称,这是我卡住的地方。如果有人有任何想法,这将帮助我很多。从下拉菜单中捕获用户所选值的数据库ID
继承人的第一页
<?php
//Template for all pages
$pagename="Select File Associations";
session_start();
include ("mysqli_test.php");
// css style sheet for template
echo "<link rel=stylesheet type=text/css href=stylesheet.css>";
// displays name in window tab
echo "<title>".$pagename."</title>";
// use header file
include("header.html");
// display the current date and time
echo date ('l d F Y H:i:s');
echo "<p></p>";
// display page name on the page
echo "<h2>".$pagename."</h2>";
$testsql = "SELECT testID, testName from tests";
$testresult = mysql_query($testsql);
echo "<td>Select Test:</td>";
echo "<select name= testName>";
while ($row = mysql_fetch_array($testresult))
{
echo "<option value=\"". $row['testID']."\">". $row['testName']. "</option>";
}
echo "</select>";
echo "<form method=post action= confirm_selection2.php>";
echo "<tr><td><input type=submit value='Submit'></td>";
echo "<td><input type=reset value='clear'></td></tr>";
// use footer file
include("footer.html");
?>
那么表单处理页面confirm_selections.php代码
<?php
//Template for all pages
$pagename="confirm_selection";
session_start();
include ("mysqli_test.php");
// css style sheet for template
echo "<link rel=stylesheet type=text/css href=stylesheet.css>";
// displays name in window tab
echo "<title>".$pagename."</title>";
// use header file
include("header.html");
// display the current date and time
echo date ('l d F Y H:i:s');
echo "<p></p>";
// display page name on the page
echo "<h2>".$pagename."</h2>";
// retrieve POST data from the user selected test
$testselection=$_POST['testName'];
// check if the selections were made
if(isset($testselection)){
$instestSQL = "INSERT INTO test_performance SET
testID='$testselection'
testerID='$_SESSION['testID']);
$exeintestSQL=mysql_query($instestSQL) OR die(mysql_error());
}
// use footer file
include("footer.html");
?>
非常感谢你的那个男人,你不知道这会给我带来多大的压力,我真的应该知道这一点。 – 2013-03-04 21:53:27