我目前正在尝试为剧院建立预订系统。我有5个不同的作品,可以在我的数据库中找到,并在php中查询。
我有一张表格,显示了产品及其相关的门票价格。每行都说明生产,票价和提交按钮(使用$ _POST)来选择生产。
我正在尝试将所选作品的标题作为制作_'制作标题'发送。例如如果选择了hamlet,我将使用$ _POST [' production_hamlet']检索选择。
但是我不知道在检索POST时如何替换查询中找到的每个产品的标题。
e.g。在下一页上回声,看看它是否已提交我在回复$ POST ['生产 .....&#后不知道该怎么写39;]
这是我的代码:
<form method="post" action="choose_performance.php">
<table name="choose_performance">
<thead id="td">
<tr>
<td>Production</td>
<td>Basic Ticket Price</td>
<td>Select</td>
</tr>
<thead>
<tbody>
<?php
$production_set = find_productions();
while($row = mysqli_fetch_assoc($production_set)){?>
<tr>
<td><?php echo $row['Title']?>
<input type="hidden" name="<?php echo "production_".$row['Title']?>" value="<?php echo $row['Title']?>" />
</td>
<td><?php echo $row['BasicTicketPrice'];?>
<input type="hidden" name="<?php echo "price_".$row['Title']?>" value="<?php echo $row['BasicTicketPrice']?>" />
</td>
<td>
<input type="submit" name="submit" value="Submit"
onclick='alert("Thank you for your selection. Please choose your preferred performance time and date on the next page.");'>
</td>
</tr>
<?php
}
?>
</form>
关于如何检索POST的任何建议都会很棒。
感谢。
答案 0 :(得分:0)
只需将<form>
标记放在while
循环中,以便每行都有自己的提交表单。这样,当提交表单时,您只有2个已发布的参数(生产和价格)。见下文:
<tr>
<td>
<?php echo $row[ 'Title']?>
</td>
<td>
<?php echo $row[ 'BasicTicketPrice'];?>
</td>
<td>
<form method="post" action="choose_performance.php">
<input type="hidden" name="production" value="<?php echo $row['Title'] ?>" />
<input type="hidden" name="price" value="<?php echo $row['BasicTicketPrice'] ?>" />
<input type="submit" name="submit" value="Submit" onclick='alert("Thank you for your selection. Please choose your preferred performance time and date on the next page.");'>
</form>
</td>
</tr>