我有一个表
EVENTCODE EVENTNAME VENUE DATE ACTION
001 Concert Here 09/13 Reserve Now
002 Sports Here 09/12 Reserve Now
我有一个表单弹出当我点击"现在预订"
EVENTNAME: ------ (fetch)
VENUE: --------- (fetch)
DATE: ------ (fetch)
Full Name: ---- (user input)
Contact No.: ----- (user input)
Email: ----- (user input)
[SUBMIT BUTTON]
我的问题是,如何显示数据库中的某个数据独立?比如当我在第一个条目(EVENTCODE 001)上点击"现在预订"时,反映第一个条目上的EVENTNAME、VENUE、DATE在表格上?你如何获取那个"反射",这样我就可以将其记录为另一个类似事务的表?
我真的很恼火,因为我想不出一个伪代码或它的逻辑。请帮助。谢谢!
下面是我的代码:<?php
if(mysqli_num_rows($qr)==0){
echo ("No record fetched...<br>");
}//end no record
else{//there is/are record(s)
?>
<div class="scroll" style="height:200px; overflow:scroll;" >
<table width="100%" border="1" class="altrowstable" id="alternatecolor">
<tr align="center">
<th>Name</th>
<th>Venue</th>
<th>Date & Time</th>
<th> </th>
</tr>
<?php
while ($record=mysqli_fetch_array($qr)){//redo to other records
?>
<tr>
<td><?php echo $record['name']; ?></td>
<td><?php echo $record['venue']; ?></td>
<td><?php echo $record['date']; ?></td>
<td><a href="reservemain.php" target="reserve">Reserve Now!</a></td>
</tr>
<?php
}//end of while
?>
一种方法是将唯一标识符作为get参数传递给reservemain.php
,例如EVENTCODE。在reservemain.php
中,您可以通过给定的EVENTCODE来识别特定的记录。
一个实际的例子:
<td><a href="reservemain.php?event_code=<?php echo $rows['code']; ?>" target="reserve">Reserve Now!</a></td>
这可以在reservemain.php
和$_GET['event_code']
中检索。