【发布时间】:2017-03-31 09:49:40
【问题描述】:
我已经为这个问题苦苦挣扎了几个星期。看,我有一个带有漂亮表格的页面,它在 jquery 的帮助下是动态的。
蓝色按钮(输入[提交]),对点击做出反应并在右侧打开其他区域。 表中的所有数据都是数据库的输出。我的数据库如下所示:
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Problem Solver</title>
<link href="other/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/style.css"></head>
<body>
<!-- -------------------upper navigation------------------------------ -->
<div class="container-fluid">
<nav id="navbar" class="navbar navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="index.html">F.A.Q</a></li>
<li><a href="tech.html">Technician</a></li>
<li><a href="da.html">Delivery Analyst</a></li>
</ul>
<form action="#.php" method="post" name="search_form" class="navbar-form navbar-right" >
<input type="text" class="form-control" placeholder="Search..." name="search_field">
</form>
</nav>
<!-- -----------------------RESULTS' TABLE--------------------------->
<div class="row">
<div class="col-md-9 col-lg-9 col-sm-10 col-xs-12 main myTableBlock">
<h2 class="sub-header">Results:</h2>
<div class="table-responsive">
<?php
$dbh = new PDO("sqlite:myDB2");
$query = $dbh->prepare("SELECT * FROM myData");
$query->execute();
$result = $query->fetchall();
echo
"<table class='table table-striped table-hover' name='results_table'>
<thead>
<tr>
<th>Incident Number</th>
<th>Type of problem</th>
<th>Subject of problem</th>
<th>Date</th>
<th>Current Status</th>
</tr>
</thead>
<tbody>"
;
foreach($result as $row)
{
echo "<tr class=".$row['ID']." >";
echo "<td>" . $row['incident_number'] . "</td>";
echo "<td>" . $row['incident_type'] . "</td>";
echo "<td>" . $row['incident_subject'] . "</td>";
echo "<td>" . $row['incident_time'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "<td>" ."<form action='myOpennerOutput.php' method='GET'>"."<input type='hidden' name='my_inc_number' value=". $row['incident_number'] .">"."<input type='submit' name='trigger' value='Show Actions' class='btn btn-primary' data-toggle='collapse' href='#collapseExample' aria-expanded='false' aria-controls='collapseExample'>". "</form>". "</td>";
}
echo "</tr>";
echo "</tbody>";
echo "</table>";
?>
</div>
</div>
<!-- ---------------------------------OPENNER BLOCK --------------->
<div class="col-md-2 sidebar myOpenner col-md-pull-1 col-lg-2 col-lg-pull-1 col-sm-2 col-sm-pull-1 col-xs-2 col-xs-pull-1">
<div class="collapse" id="collapseExample">
<div class="well">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<form action="#.php" method="post">
<label id="incident_number">Incident nr.:</label>
<textarea name="actionsByTech" rows="5" cols="30" placeholder="Technician's actions:"></textarea><br>
<br>
<textarea name="da_description" rows="5" cols="30" placeholder="DA's description:"></textarea></br>
<div class=" col-md-12 text-center">
<input type="submit" class="btn btn-primary" value="Update">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- ----------------OPENNER END ------------------>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="other/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</body>
</html>
我的问题:我想从数据库中的 myActions 表中获取“动作”,并通过右键单击蓝色按钮“显示动作”将其放入字段中。每个动作都与现场的不同行相关联。因此,第一行的事件编号为 999,我想从数据库中的该记录中获取操作,并将其放在右侧的字段中。如果你能帮助我,我将不胜感激。谢谢!
【问题讨论】:
-
您自己尝试过还是想聘请开发人员?
-
对!到目前为止你尝试过什么?
-
目前我的蓝色按钮有一些问题 - 它有引导类 data-toggle:collapse,这使得无法使用 type[submit] - 因为有两个操作。所以现在只有两个解决方案:我必须删除我的类型[提交] - 然后我不能发送任何数据,或者删除数据切换 - 然后我不能从右边打开字段
标签: javascript php html mysql database