选择具有多个所选选项的多个返回到许多选项

时间:2017-10-10 10:54:55

标签: php forms mysqli

我有一个包含2个选择倍数的表单。 我得到了2个函数的数据。 问题是如果客户端有多个选定的选项。 我得到的所有内容都是在客户选择值时返回的。

如果有5个选项选择1 =我有5个选项,其中一个被选中。 如果有5个选项,其中2个被选中=我得到10个选项(每个选项中有2个")并且选择了一个选项。

如果我尝试添加" GROUP BY NAME"在SELECT中,我得到了正确的选项,但只选择了一个。

你可以告诉我我错过了什么吗? function GetTheArea() {

include 'dbconn.php';
$client_id = $_GET['id'];

$query = "SELECT applicant_location.APPLICANT, applicant_location.LOCATION, 
location.NAME, location.LOCATION_ID FROM applicant_location , location WHERE 
applicant_location.APPLICANT = $client_id";
$result = mysqli_query($conn, $query);

while ($row = mysqli_fetch_assoc($result)) {
    if ($row["LOCATION_ID"] === $row["LOCATION"]) {
        $usedornot = "selected=\"selected\"";
    echo "<option value=\"" . $row["LOCATION_ID"]."\" 
".$usedornot.">".$row["NAME"]."</option>";
} else {
    echo "<option value=\"" . $row["LOCATION_ID"]."\">".$row["NAME"]."
</option>";
  }
 }
}
function GetTheProf() {
    include 'dbconn.php';
    $client_id = $_GET['id'];
$query = "SELECT applicant_profession.APPLICANT, 
applicant_profession.PROFESSION, profession.`NAME`, profession.PROFESSION_ID 
FROM applicant_profession , profession WHERE applicant_profession.APPLICANT = $client_id";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
    if ($row["PROFESSION"] === $row["PROFESSION_ID"]) {
        $usedornot = "selected=\"selected\"";
    echo "<option value=\"" . $row["PROFESSION_ID"]."\" 
".$usedornot.">".$row["NAME"]."</option>";
} else {
    echo "<option value=\"" . $row["PROFESSION_ID"]."\">".$row["NAME"]."
</option>";
  }
 }
}

include 'dbconn.php'; $client_id = $_GET['id']; $query = "SELECT applicant_location.APPLICANT, applicant_location.LOCATION, location.NAME, location.LOCATION_ID FROM applicant_location , location WHERE applicant_location.APPLICANT = $client_id"; $result = mysqli_query($conn, $query); while ($row = mysqli_fetch_assoc($result)) { if ($row["LOCATION_ID"] === $row["LOCATION"]) { $usedornot = "selected=\"selected\""; echo "<option value=\"" . $row["LOCATION_ID"]."\" ".$usedornot.">".$row["NAME"]."</option>"; } else { echo "<option value=\"" . $row["LOCATION_ID"]."\">".$row["NAME"]." </option>"; } } } function GetTheProf() { include 'dbconn.php'; $client_id = $_GET['id']; $query = "SELECT applicant_profession.APPLICANT, applicant_profession.PROFESSION, profession.`NAME`, profession.PROFESSION_ID FROM applicant_profession , profession WHERE applicant_profession.APPLICANT = $client_id"; $result = mysqli_query($conn, $query); while ($row = mysqli_fetch_assoc($result)) { if ($row["PROFESSION"] === $row["PROFESSION_ID"]) { $usedornot = "selected=\"selected\""; echo "<option value=\"" . $row["PROFESSION_ID"]."\" ".$usedornot.">".$row["NAME"]."</option>"; } else { echo "<option value=\"" . $row["PROFESSION_ID"]."\">".$row["NAME"]." </option>"; } } }

0 个答案:

没有答案