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"];}
非常感谢任何帮助!感谢
答案 0 :(得分:0)
试试这段代码:
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"];}
答案 1 :(得分:0)
我自己解决了这个挑战。一些结构性逻辑挑战。案件结案