我从查询中循环访问数据库。此循环显示对象名称列表并将对象值设置为单选值。
我有的是一张桌子。一旦单击单选按钮,它应该显示查询信息的重置。对象大约有 1,100 个对象,并且在不断变化。
我不确定如何获取所选单选按钮的值并将其分配给名为 "$ObjIndex" 的变量,$ObjIndex 将定义 $myQ9 将如何运行注意:如果我输入 $ObjIndex = '1407' 它工作正常; (这是对象索引值之一。
这是我的代码:
<form name="myform" actiopn="<?php $_PHP_SELF ?>" method="get">
<?php
$myQ1 = mysql_query("SELECT `iDocuments`.`File`.`FileIndex`, `iDocuments`.`File`.`FileName`, `iDocuments`.`Object`.`ObjectIndex`, `iDocuments`.`Object`.`ObjectName`, `iDocuments`.`Version`.`Version`, `iDocuments`.`File`.`UploadDate` FROM `iDocuments`.`Version` INNER JOIN `iDocuments`.`Object` ON `iDocuments`.`Object`.`ObjectIndex` = `iDocuments`.`Version`.`ObjectIndex` JOIN `iDocuments`.`File` ON `iDocuments`.`Version`.`FileIndex` = `iDocuments`.`File`.`FileIndex` WHERE `Object`.`ObjectStatus` = '1' AND `Version`.`Version` = ( SELECT MAX(`Version`) FROM `iDocuments`.`Version` WHERE `Version`.`ObjectIndex` = `Object`.`ObjectIndex` ) ORDER BY `Object`.`ObjectName` ASC");
if (!$myQ1)
{
echo 'Could not run query 1: ' . mysql_error();
}
else
{
$row1 = mysql_query($myQ1);
while( $row1 = mysql_fetch_array($myQ1) )
{
echo "<td><input type='radio' name='tog' id='tog' onClick='gtdoc()' value='$row1[2]'>$row1[3]</input></td></tr>";
}
$myQ9 = mysql_query("SELECT `iDocuments`.`File`.`FileIndex`, `iDocuments`.`File`.`FileName`, `iDocuments`.`Object`.`ObjectIndex`, `iDocuments`.`Object`.`ObjectName`, `iDocuments`.`Version`.`Version`, `iDocuments`.`File`.`UploadDate` FROM `iDocuments`.`Version` INNER JOIN `iDocuments`.`Object` ON `iDocuments`.`Object`.`ObjectIndex` = `iDocuments`.`Version`.`ObjectIndex` JOIN `iDocuments`.`File` ON `iDocuments`.`Version`.`FileIndex` = `iDocuments`.`File`.`FileIndex` WHERE `Object`.`ObjectStatus` = '1' AND `Version`.`Version` = ( SELECT MAX(`Version`) FROM `iDocuments`.`Version` WHERE `Version`.`ObjectIndex` = `Object`.`ObjectIndex` ) AND `Object`.`ObjectIndex` = '$ObjIndex'");
if (!$myQ9)
{
echo 'Could not run query 9: ' . mysql_error();
}
else
{
$row9 = mysql_query($myQ9);
while( $row9 = mysql_fetch_array($myQ9) )
{
echo "<table name='doclist'>
<tr><td>FileID</td><td><input name='DocFileID' type='text' readonly='true' value='$row9[0]'></input></td></tr>
<tr><td>File Name</td><td><input name='DocFileName' type='text' readonly='true' value='$row9[1]'></input></td></tr>
<tr><td>ObjectID</td><td><input name='DocID' type='text' readonly='true' value='$row9[2]'></input></td></tr>
<tr><td>Object Name</td><td><input name='DocName' type='text' readonly='true' value='$row9[3]'></input></td></tr>
<tr><td>Current Version</td><td><input name='CurrVer' type='text' readonly='true' value='$row9[4]'></input></td></tr>
<tr><td>Update Date</td><td><input name='lstupdate' type='text' readonly='true' value='$row9[5]'></input></td> </tr>
</table>";
}
} ?>
</form>