【发布时间】:2016-11-14 09:57:47
【问题描述】:
我的按钮有问题。我会尽力解释。 1)我有来自 postgresql 的用户 db 和 ms sql 中的新 db。 2)在表中创建有 2 列的站点(“SELECT * from users”-postgresql ):它们是 id/user 3)然后添加了包含提交按钮的新列“操作员”,提交按钮的功能正在从 ms sql db 更新“访问”列。
问题: 它为我在 ms sql 中拥有的所有数据打印所有按钮(我在 ms sql 中有 7 行数据,它为每行打印 7 个按钮),我需要为每行“回显”1 个按钮,这将是可变的。如果 access==1 则应命名为 Active ,否则应命名为 Diactive 。
这是我得到的代码和图片:
<?php
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Operator</th>
<th>View</th>
</tr>
<?php
while ($row = pg_fetch_array($result)) {
?>
<tr>
<td>
<?php
$id = $row["id"];
echo $id;
?>
</td>
<td>
<?php
$username = $row["username"];
echo $username;
?>
</td>
<td>
<form method="POST" action="oper.php">
<?php
include ("db.php");
$result2 = pg_query($db_connection, "SELECT * from users ORDER by id asc");
while ($row1 = pg_fetch_array($result2))
{
$iddrain= $row1['id'];
//echo $iddrain;
//echo $iddrain;
$q7= "Select access from nezeret where id_m=$iddrain";
//var_dump($q7);
$resultid= sqlsrv_query($link, $q7, $params, $options);
while($row7= sqlsrv_fetch_array($resultid))
{
//$rs7=$row7['ID_M'];
$rs8=$row7['access'];
//echo $rs8;
//break;
if($rs8==1)
{
echo "<p><input type=\"submit\" name=\"uid\" value=Operator-ON onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
else
{
echo "<p><input type=\"submit\" name=\"uid\" value=DIavtive onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
}
}
?>
</form>
</td>
<?php
}
?>
</tr>
</table>
?>
【问题讨论】:
-
将 放入循环中 if else 条件 make
value="Deavtive"value="Active"
标签: php sql-server button input submit