这是一些伪代码
echo "<table class='container'><tr class='stuff'></tr>
<form method='post' action='edit.php' name='edit'>
<tr class='setting' hidden>
... Some inputs and such go here...
<td class='checkbox'>
<input class='cancel' type='button'>
<input class='save' name='update' value='update' type='submit'>
</td></tr></form></table>";
编辑:这是实际的代码
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
if($_SESSION['school'] == "drl") {
$sql = 'SELECT id, student_name, student_id, grad_year, grade, test_name, individual, team_event, member_number, team_number, captain FROM drl';
}
elseif($_SESSION['school'] == "Butler Tech") {
$sql = 'SELECT id, student_name, student_id, grad_year, grade, test_name, individual, team_event, member_number, team_number, captain FROM butlertech';
}
elseif($_SESSION['school'] == "MIT") {
$sql = 'SELECT student_name, student_id, grad_year, grade, test_name, individual, team_event, member_number, team_number, captain FROM mit';
}
mysql_select_db('contestants');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo
"<table class='container'><tr class='stuff'><td hidden>{$row['id']}</td><td>{$row['student_name']}</td></input><td>{$row['student_id']}</td><td class='shcell'>{$row['grade']}</td><td>{$row['test_name']}</td><td>{$row['individual']}</td><td>{$row['team_event']}</td><td class='shcell'>{$row['team_number']}</td><td class='shcell'>{$row['captain']}</td><td class='checkbox' class='odd'> <input class='edit' type='button'> <input class='delete' type='button'> </td></tr>
<tr class='setting' hidden> <form method='post' action='edit.php' name='edit'>
<td><input type='text' name='id' value='"; echo $row['id']; echo "' hidden></input><input id='school' value='"; echo $_SESSION['school']; echo "'name='school' hidden>
<input id='student_name' type='text' value='{$row['student_name']}' name='student_name' /></td>
<td><input id='student_id' type='text' value='{$row['student_id']}' name='student_id' /></td>
<td class='shcell'><select id='grade' name='grade'>
<option value = '7th'"; if($row['grade'] == '7'){ echo 'selected="selected"';} echo ">7th</option>
<option value = '8th'"; if($row['grade'] == '8'){ echo 'selected="selected"';} echo ">8th</option>
<option value = '9th'"; if($row['grade'] == '9'){ echo 'selected="selected"';} echo ">9th</option>
<option value = '10th'"; if($row['grade'] == '10'){ echo 'selected="selected"';} echo ">10th</option>
<option value = '11th'"; if($row['grade'] == '11'){ echo 'selected="selected"';} echo ">11th</option>
<option value = '12th'"; if($row['grade'] == '12'){ echo 'selected="selected"';} echo ">12th</option>
</select></td>
<td><select class='settings' id='test_name' name='test_name'>
<option value = 'None'"; if($row['captain'] == 'None'){ echo 'selected="selected"';} echo ">None</option>
<option value = '(01) Fundamental Accounting'"; if($row['test_name'] == '(01) Fundamental Accounting'){ echo 'selected="selected"';} echo ">(01) Fundamental Accounting</option>
<option value = '(02) Advanced Accounting'"; if($row['test_name'] == '(02) Advanced Accounting'){ echo 'selected="selected"';} echo ">(02) Advanced Accounting</option>
<option value = '(04) Payroll Accounting"; if($row['test_name'] == '(04) Payroll Accounting'){ echo 'selected="selected"';} echo "'>(04) Payroll Accounting</option>
<option value = '(12) Financial Math & Analysis'"; if($row['test_name'] == '(12) Financial Math & Analysis'){ echo 'selected="selected"';} echo ">(12) Financial Math & Analysis</option>
<option value = '(13) Insurance Concepts'"; if($row['test_name'] == '(13) Insurance Concepts'){ echo 'selected="selected"';} echo ">(13) Insurance Concepts</option>
<option value = '(14) Federal Income Tax Accounting'"; if($row['test_name'] == '(14) Federal Income Tax Accounting'){ echo 'selected="selected"';} echo ">(14) Federal Income Tax Accounting</option>
<option value = '(20) Keyboarding Production'"; if($row['test_name'] == '(20) Keyboarding Production'){ echo 'selected="selected"';} echo ">(20) Keyboarding Production</option>
<option value = '(46) Fundamentals of Web Design'"; if($row['test_name'] == '(46) Fundamentals of Web Design'){ echo 'selected="selected"';} echo ">(46) Fundamentals of Web Design</option>
<option value = '(47) PC Servicing & Troubleshooting'"; if($row['test_name'] == '(47) PC Servicing & Troubleshooting'){ echo 'selected="selected"';} echo ">(47) PC Servicing & Troubleshooting</option>
<option value = '(48) Computer Security'"; if($row['test_name'] == '(48) Computer Security'){ echo 'selected="selected"';} echo ">(48) Computer Security</option>
</select></td>
<td><select class='settings' name='individual' value='{$row['individual']}'>
<option value = 'None'"; if($row['individual'] == 'None'){ echo 'selected="selected"';} echo ">None</option>
<option value = '(03) Computerized Accounting'"; if($row['individual'] == '(03) Computerized Accounting'){ echo 'selected="selected"';} echo ">(03) Computerized Accounting</option>
<option value = '(06) Fundamental Spreadsheet Applications'"; if($row['individual'] == '(06) Fundamental Spreadsheet Applications'){ echo 'selected="selected"';} echo ">(06) Fundamental Spreadsheet Applications</option>
<option value = '(07) Advanced Spreadsheet Applications'"; if($row['individual'] == '(07) Advanced Spreadsheet Applications'){ echo 'selected="selected"';} echo ">(07) Advanced Spreadsheet Applications</option>
<option value = '(08) Banking & Finance'"; if($row['individual'] == '(08) Banking & Finance'){ echo 'selected="selected"';} echo ">(08) Banking & Finance</option>
<option value = '(10) Economic Research Project Individual'"; if($row['individual'] == '(10) Economic Research Project Individual'){ echo 'selected="selected"';} echo ">(10) Economic Research Project Individual</option>
<option value = '(21) Fundamental Word Processing Skills'"; if($row['individual'] == '(21) Fundamental Word Processing Skills'){ echo 'selected="selected"';} echo ">(21) Fundamental Word Processing Skills</option>
<option value = '(22) Advanced Word Processing Skills'"; if($row['individual'] == '(22) Advanced Word Processing Skills'){ echo 'selected="selected"';} echo ">(22) Advanced Word Processing Skills</option>
<option value = '(31) Administrative Support Research Project Individual'"; if($row['individual'] == '(31) Administrative Support Research Project Individual'){ echo 'selected="selected"';} echo ">(31) Administrative Support Research Project Individual</option>
<option value = '(64) Interview Skills'"; if($row['individual'] == '(64) Interview Skills'){ echo 'selected="selected"';} echo ">(64) Interview Skills</option>
<option value = '(69) Presentation Management Individual'"; if($row['individual'] == '(69) Presentation Management Individual'){ echo 'selected="selected"';} echo ">(69) Presentation Management Individual</option>
</select></td>
<td><select class='settings' name='team_event' value='{$row['team_event']}'>
<option value = 'None'"; if($row['team_event'] == 'None'){ echo 'selected="selected"';} echo ">None</option>
<option value = '(09) Financial Analyst Team'"; if($row['team_event'] == '(09) Financial Analyst Team'){ echo 'selected="selected"';} echo ">(09) Financial Analyst Team</option>
<option value = '(11) Economic Research Project Team'"; if($row['team_event'] == '(11) Economic Research Project Team'){ echo 'selected="selected"';} echo ">(11) Economic Research Project Team</option>
<option value = '(30) Administrative Support Team'"; if($row['team_event'] == '(30) Administrative Support Team'){ echo 'selected="selected"';} echo ">(30) Administrative Support Team</option>
<option value = '(50) Computer Animation Team'"; if($row['team_event'] == '(50) Computer Animation Team'){ echo 'selected="selected"';} echo ">(50) Computer Animation Team</option>
<option value = '(51) Network Design Team'"; if($row['team_event'] == '(51) Network Design Team'){ echo 'selected="selected"';} echo ">(51) Network Design Team</option>
<option value = '(53) Video Production Team'"; if($row['team_event'] == '(53) Video Production Team'){ echo 'selected="selected"';} echo ">(53) Video Production Team</option>
<option value = '(55) Web Site Design Team'"; if($row['team_event'] == '(55) Web Site Design Team'){ echo 'selected="selected"';} echo ">(55) Web Site Design Team</option>
<option value = '(57) Broadcast News Production Team'"; if($row['team_event'] == '(57) Broadcast News Production Team'){ echo 'selected="selected"';} echo ">(57) Broadcast News Production Team</option>
<option value = '(62) Small Business Management Team'"; if($row['team_event'] == '(62) Small Business Management Team'){ echo 'selected="selected"';} echo ">(62) Small Business Management Team</option>
<option value = '(70) Presentation Management Team'"; if($row['team_event'] == '(70) Presentation Management Team'){ echo 'selected="selected"';} echo ">(70) Presentation Management Team</option>
</select></td>
<td class='shcell'><input id='team_number' name='team_number' min='1' value='{$row['team_number']}' class='number' type='number' /></td>
<td class='shcell'><select id='captain' name='captain'>
<option value = '-'"; if($row['captain'] == '-'){ echo 'selected="selected"';} echo ">-</option>
<option value = 'No'"; if($row['captain'] == 'No'){ echo 'selected="selected"';} echo ">No</option>
<option value = 'Yes'"; if($row['captain'] == 'Yes'){ echo 'selected="selected"';} echo ">Yes</option>
</select></td>
<td class='checkbox'>
<input class='cancel' type='button'>
<input class='save' name='update' value='update' type='submit'></td></form></tr></table>";}
mysql_close($conn);
?>
一切都按预期工作,除了表单部分。正如您在图片中看到的那样,表单在其他所有内容之前都被回显。我想要的是<tr class='setting' hidden></tr>
在表格内。