dongshao6591
2018-07-12 07:56 阅读 50
已采纳

php下拉框变量中的空格

I am trying to retrieve data field from a database and store them in a dropdown box so that they correlate to each other which i have done but when I put them into a dropdown box they appear but with no spaces between them and I want the words separated. Any help much appreciated.

<form name="FrmAmend" method="post" action="amenddvd2.php">
Select from the list below<br>
<select name="Film" t[enter link description here][1]itle="Select DVD">
    <option value="" selected disabled>Select DVD</option>
<?php

$result = mysqli_query($con, "SELECT `DVD ID`, `Title`, `Certificate` FROM tbldvd;");
while ($row = mysqli_fetch_assoc($result)) {
    echo "<option value='" . $row['DVD ID'] . $row['Title'] . $row['Certificate'] . "'>" . $row['DVD ID'] . $row['Title'] . $row['Certificate'] . "</option>";

}
?>
</select><br>
<a href="menu.php"</a>Return To Main Menu<br>
<input type="submit" name="Submit" value="Select DVD">
</a>
</form>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    du8980919 du8980919 2018-07-12 08:28

    It will be better you do it this way

        <form name="FrmAmend" method="post" action="amenddvd2.php">
    Select from the list below<br>
    <select name="Film" t[enter link description here][1]itle="Select DVD">
    <option value="" selected disabled>Select DVD</option>
    <?php
    
    $result = mysqli_query($con, "SELECT `DVD ID`, `Title`, `Certificate` FROM tbldvd;");
    while ($row = mysqli_fetch_assoc($result)) {
    ?>
        <option value=' <?php echo"$row['DVD ID'] $row['Title'] $row['Certificate']" ?> ' selected disabled>Select DVD</option>
    <?php
     }
    ?>
       </select><br>
    <a href="menu.php"</a>Return To Main Menu<br>
    <input type="submit" name="Submit" value="Select DVD">
    </a>
    </form>
    
    点赞 评论 复制链接分享
  • douji1853 douji1853 2018-07-12 08:01

    concat a space between the vars

    echo "<option value='" . $row['DVD ID'] . $row['Title'] . $row['Certificate'] . "'>" . $row['DVD ID'] . ' ' . $row['Title'] . ' ' . $row['Certificate'] . "</option>";
    
    点赞 评论 复制链接分享

相关推荐