单击按钮时,在另一页上显示所选行



我有一个表格,读出数据库的几列,每行都有一个编辑按钮。我要做的就是,当单击编辑按钮时,该行及其所有列都显示在另一个页面中。任何帮助都会很棒。我知道这很简单,但我可以让它工作。我能够导航到下一页,但不确定如何携带特定行的 id 并将其读出。谢谢。

index. php
<form id="mainform" action="editFunding2.php">
<div class='row'>
<div class='col-12'>
<div class='table table-responsive'>
<table class='table table-striped table-bordered datatable active' id='grantTable'>
<thead>
<tr>
<th>FP ID</th>
<th>Short Title</th>
<th>PI</th>
<th>Department</th>
<th>Funding Type</th>
<th>Change Funding Type</th>
</tr>
</thead>
<tbody>
<?php
//Foreach loop iterates through each column of $getallrows function
foreach($allRows as $rowID => $rowInfo){ ?>
<tr>
<td><?php echo $rowInfo['fpID'];?></td>
<td><?php echo $rowInfo['shortTitle'];?></td>
<td><?php echo $rowInfo['PI'];?></td>
<td><?php echo $rowInfo['Department'];?></td>
<td><?php echo $rowInfo['fundingType'];?></td>
<!--Create dynamic id -->
<?php $rdDrop = "ddgrantType_".$rowInfo['fpID'];?>
<td>
<button type="submit" class="btn btn-danger" name="action" value='Change Funding Type'>Change Funding</button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</form>
My editFunding2.php page
<div class='row'>
<div class='col-12'>
<div class='table table-responsive'>
<table class='table table-striped table-bordered datatable active' id='grantTable'>
<thead>
<tr>
<th>FP ID</th>
<th>Short Title</th>
<th>PI</th>
<th>Department</th>
<th>Division</th>
<th>Sponsor Name</th>
<th>Project Start</th>
<th>Project End</th>
<th>Funding Type</th>
<th>Yes/No</th>
<th>Proper Type If No</th>
<!-- <th>Exclusions</th>
<th>FP Durtation</th> -->
<th>Comment</th>
</tr>
</thead>
<tbody>
<?php
session_start();
$editRow = $_REQUEST['fpID'];
$mssql = mysqli_query("SELECT * FROM spacing.METADATA_WEBFORM WHERE FUNDING_PROPOSAL_ID = $fpID' ") or die (mysqli_error());
while($rowInfo = mysqli_fetch_array($mssql)) {
?>
<tr>
<td><?php echo $rowInfo['fpID'];?></td>
<td><?php echo $rowInfo['shortTitle'];?></td>
<td><?php echo $rowInfo['PI'];?></td>
<td><?php echo $rowInfo['Department'];?></td>
<td><?php echo $rowInfo['Division'];?></td>
<td><?php echo $rowInfo['sponsorName'];?></td>
<td><?php echo $rowInfo['Date_Project_Start']->format('Y-m-d');?></td>
<td><?php echo $rowInfo['Date_Project_End']->format('Y-m-d');?></td>
<td><?php echo $rowInfo['fundingType'];?></td>
<?php } ?>
<!--Create dynamic id -->
<?php $rdDrop = "ddgrantType_".$rowInfo['fpID'];?>
<td>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class='form-check-input' name="rdGrant[<?php echo $rowInfo['fpID'];?>]" value="Yes" id="rdYes" onclick="disable('<?php echo $rdDrop;?>')" checked/> Yes
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class='form-check-input' type="radio" name="rdGrant[<?php echo $rowInfo['fpID'];?>]" value="No" id="rdNo" onclick="enable('<?php echo $rdDrop;?>')"/> No
</label>
</div>
</td>
<td>
<div class="dropdown">
<select class='form-control' name="ddgrantGroup[<?php echo $rowInfo['fpID'];?>]" id="<?php echo $rdDrop;?>" disabled>
<option value=''>Select Proper Funding Type</option>
<option value="Corporate Sponsor">Corporate Sponsor</option>
<option value="Federal">Federal</option>
<option value="Foundation Selected">Foundation Selected</option>
<option value="Internally Funded">Internally Funded</option>
<option value="State/Local">State/Local</option>
</select>
</div>
</td>
<td>
<div class="comment">
<textarea class="form-control" aria-label="With textarea" name="grantComment[<?php echo $rowInfo['fpID'];?>]" id="grantComment" placeholder="Comments"></textarea>
</div>
</td>
</tr>
</tbody>
</div>
</div>
</div>
<div class='row'>
<div class='col-12 text-right'>
<button type="submit" class="btn btn-secondary formsubmitbttn" name="action" value='save'>Save</button>
<button type="submit" class="btn btn-primary formsubmitbttn" name="action" value='complete'>Complete and Save</button>
</div>
</div>
</div>

将按钮更改为

<a href="editFunding2.php?id=<?= $rowInfo['fpID']; ?>">My Link to xx</a>

在编辑资金2.php :

$editRow = $_GET['id'];

最新更新