I can't get figure out where to close off my td tag in table


I have the following code and it does display all the option in the drop down box but I have just noticed that I am missing the </td> somewhere. I tried to place the </td> after my second option tag but for some reason, it doesn't work... Just display all my options outside of table: This is my code: I have tried to place the td tag in all sort of places but not even sure whether I need the td at all here.....

<?php
include_once __DIR__.'/header2.php';
if(!$_SESSION['u_uid']) {
  echo "<meta http-equiv='refresh' content='0;url=index.php?create_music_sub=notlogin'>"; 
   exit();
} else {
if($_SESSION['u_permission'] == 0){
    echo "<meta http-equiv='refresh' content='0;url=header2.php?create_music_sub=nopermission'>"; 
    exit();
} else {

    $date = date("Y-m-d H:i:s");


    $sql = "SELECT * FROM music_forum_cats;";

                 $stmt = mysqli_stmt_init($conn);

                if(!mysqli_stmt_prepare($stmt, $sql)) {
                       echo "SQL error";
                    } else {
                 //    mysqli_stmt_bind_param($stmt, "i", $admin);
                      mysqli_stmt_execute($stmt);

                 $result = mysqli_stmt_get_result($stmt);
                      $resultCheck = mysqli_num_rows($result);





                 echo '<form action="create_music_sub_process.php" method="POST">';

                 echo '<table class="create_music_sub">

                      <tr>
                      <th colspan="3" class="update_title">Welcome to the Create Music Sub Category Section '.$_SESSION['u_first'].' '.$_SESSION['u_last'].'</th>
                      </tr>
                      <tr>
                      <th>Category:</th><td>';

                     echo '<select name="create_music_sub"><option disabled selected>Pick a Category</option>';
                while($row = mysqli_fetch_assoc($result)) {

                    $id = $row['id'];


                    echo '<option value="',htmlspecialchars($id),'">',htmlspecialchars($row['category']),'</option></td>';



                     }







                     echo '<tr>
                      <th>Sub Category:</th><td><input type="text" name="sub_cat" placeholder="Create Music Sub Category"></td>
                      </tr>
                      <tr>
                      <th>Creator:</th><td>',htmlspecialchars($_SESSION["u_uid"]),'</td>
                      </tr>
                      <tr>
                      <th>Date Created:</th><td><input type="text" name="date" value="',htmlspecialchars($date),'"></td>
                      </tr>
                      <tr>
                      <th></th><td colspan="2"><input type="submit" name="submit" value="Create Sub Category"></td>
                      </tr>
                       </select></td></tr>
                      </table>
                    </form>';
                        }
                } 

                  }


              include_once __DIR__. '/footer.php';
            ?>
- - Source

Answers

answered 1 week ago Ass3mbler #1

You should remove the "</td>" after each <option> tag, add a closing "</select>" tag after all the <option> tags and add the </td> there. I think that validating your output could help you. Try using this tool

comments powered by Disqus