gpt4 book ai didi

php - 在 PHP 中的同一表单上需要两个下拉列表

转载 作者:行者123 更新时间:2023-11-30 21:58:59 25 4
gpt4 key购买 nike

Wanted result Result - error- trying to use two statements

我尝试了好几天才成功地建立了一个表单,该表单可以给我两个下拉框,我可以在其中从同一数据库中的不同表中选择记录。我的目标是能够将酒店房间从一个参与者转移到另一个参与者。为此,我需要能够先选择房间捐赠者,然后再选择接受者。我在 cms 中执行此操作,因此我必须能够从同一 PHP 脚本中进行此选择。

一旦包含第二个选项,我就会遇到问题。我不明白如何在同一个表单上实现两个选择选项。有人能帮我解决吗?这是我的代码:


    if (!isset($_POST['selected']))
{
$DonorSelect = "Select * from rog_jomres_guests where property_uid in ($RallyHotels) order by surname";
$DonorResult = mysql_query($DonorSelect) or die("Donor lookup Query failed" . mysql_error());
$numrecords=mysql_num_rows($DonorResult); $rows = 0;
?>
<html>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
<select name="donor">
<?php
while ($JosRow = mysql_fetch_array($DonorResult))
{
$Name = $JosRow['guests_uid'] . " " . $JosRow['surname'] . "," . $JosRow['firstname'];
$id = $JosRow['mos_userid'];
$gid=$JosRow['guests_uid'];
$IDName = $Name;

$AttendSelect = "select * from rog_sembookings where userid = $id AND semid = $ThisRally";
$AttendResult = mysql_query($AttendSelect) or die("$ThisRally query failed" . mysql_error());
$AttendRow = mysql_fetch_array($AttendResult);

if ($Name == "Administrator"){ }
elseif (!$AttendRow) { }
else
{
?>
<option value="<?php echo $gid; ?>"><?php echo $IDName;?></option>
<?php
}
}
?>
</select>
<?php /**

<select name="transferto">
<?php
$RecipientSelect = "Select * from rog_users order by name";
$RecipientResult = mysql_query($RecipientSelect) or die("Recipient lookup Query failed" . mysql_error());
$Recipientrecords=mysql_num_rows($RecipientResult);
while ($RecipientRow = mysql_fetch_array($RecipientResult))
{
$RecipientName = $RecipientRow['name'];
$Recipientid = $RecipientRow['id'];
$RIDName = $RecipientName;
$PartSelect = "select * from rog_users where userid = $Recipientid";
$PartResult = mysql_query($PartSelect) or die("$ThisRally PartSelect query failed" . mysql_error());
$PartRow = mysql_fetch_array($PartResult);

if ($RecipientName == "Administrator"){ }
elseif (!$PartRow) { }
else
{
?>
<option value="<?php echo $Recipientid; ?>"><?php echo $RIDName;?></option>
<?php
}
}
?>
</select>
<?php **/ ?>

<input type="submit" value="<?php echo $Valg; ?>" name="selected">
</input>
</form>
</body>
</html>
<?php

} // end of clause if not set $_POST['selected']
else
{ // beginning clause if set $_POST['selected'] let's do this thing......

if ($AdminUser==1)
{ $CurrGuest = $_POST["donor"];}

非常感谢任何帮助!谢谢

最佳答案

试试这段代码:

if (!isset($_POST['selected']))
{
$DonorSelect = "Select * from rog_jomres_guests where property_uid in ($RallyHotels) order by surname";
$DonorResult = mysql_query($DonorSelect) or die("Donor lookup Query failed" . mysql_error());
$numrecords=mysql_numrows($DonorResult); $rows = 0;
?>
<html>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
<select name="donor">
<?php
while ($JosRow = mysql_fetch_array($DonorResult))
{
$Name = $JosRow['guests_uid'] . " " . $JosRow['surname'] . "," . $JosRow['firstname'];
$id = $JosRow['mos_userid'];
$gid=$JosRow['guests_uid'];
$IDName = $Name;

$AttendSelect = "select * from rog_sembookings where userid = $id AND semid = $ThisRally";
$AttendResult = mysql_query($AttendSelect) or die("$ThisRally query failed" . mysql_error());
$AttendRow = mysql_fetch_array($AttendResult);

if ($Name == "Administrator"){ }
elseif (!$AttendRow) { }
else
{
?>
<option value="<?php echo $gid; ?>"><?php echo $IDName;?></option>
<?php
}
}
?>
</select>

<select name="transferto">
<?php
$RecipientSelect = "Select * from rog_users order by name";
$RecipientResult = mysql_query($RecipientSelect) or die("Recipient lookup Query failed" . mysql_error());
$Recipientrecords=mysql_numrows($RecipientResult);
while ($RecipientRow = mysql_fetch_array($RecipientResult))
{
$RecipientName = $RecipientRow['name'];
$Recipientid = $RecipientRow['id'];
$RIDName = $RecipientName;
$PartSelect = "select * from rog_users where userid = $Recipientid";
$PartResult = mysql_query($PartSelect) or die("$ThisRally PartSelect query failed" . mysql_error());
$PartRow = mysql_fetch_array($PartResult);

if ($RecipientName == "Administrator"){ }
elseif (!$PartRow) { }
else
{
?>
<option value="<?php echo $Recipientid; ?>"><?php echo $RIDName;?></option>
<?php
}
}
?>
</select>

<input type="submit" value="<?php echo $Valg; ?>" name="selected">
</input>
</form>
</body>
</html>
<?php

} // end of clause if not set $_POST['selected']
else
{ // beginning clause if set $_POST['selected'] let's do this thing......

if ($AdminUser==1)
{ $CurrGuest = $_POST["donor"];}

关于php - 在 PHP 中的同一表单上需要两个下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44070055/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com