简体   繁体   中英

HTML PHP check box

How can I style my code so that the check box can be aligned beside the table.

All of the check boxes are appearing above the table, but not beside it.

Consider the following snippet of code as well as the picture attached at the end.

<html>
  <head>
    <title> Furni checker </title>
  </head>

  <body>

    <h1>Furniture Lookup / Furniture Checker</h1> <br />
    <br /><p>This tool is used for removal or check furniture on a user account.</p> <br />
    <h2> Instructions : </h2> <br />
    <p> Lookup User ID and Lookup for the Furniture! </p>

    <?php
      require_once "global.php";

      echo '<h1>Furniture Lookup / Furniture Checker</h1>
      <br /><p>This tool is used for removal or check furniture on a user account.</p>';

      echo '<br />
      <form method="post">
      Username:
      <input type="text" name="user">
      <input type="submit" value="Lookup">
      </form>';

      if (isset($_POST['user'])) {
        $user = filter($_POST['user']);
        $getUser = dbquery("SELECT * FROM users WHERE users.username = '" . $user . "' ");

        while($show1 = mysql_fetch_array($getUser)) {
          echo ''. $show1['id']. '';        
        }
      }
    ?>

    <br />

    <?php
      echo '
      <form method="post">
      ID:
      <input type="text" name="id">
      <input type="submit" value="Lookup">
      </form>';

      if (isset($_POST['id'])) {
        $id = filter($_POST['id']);
        $getFurniture = dbquery("SELECT public_name FROM furniture JOIN items ON items.base_item = furniture.id WHERE items.user_id = '" . $id . "' ORDER BY public_name ASC ");

        echo '<table border=1 cellpadding=1 width="10%">';

        while($show = mysql_fetch_array($getFurniture)) {
          //echo  ''. $show['public_name'].'' ;
          echo '<tr class="t_row">';
          echo '<input type="checkbox"> <td>' .$show['public_name']. '</td>';
          echo '</tr>';

        }

        echo '</input>';
        echo '</table>';    
      }
    ?>

Image:

checkbox_image

Try this:

          <?php


              if (isset($_POST['submit']))
              {
                      $id = filter($_POST['id']);
                      $getFurniture = dbquery("SELECT public_name FROM furniture JOIN items ON items.base_item = furniture.id WHERE items.user_id = '" . $id . "' ORDER BY public_name ASC ");

                      echo '<table border=1 cellpadding=1 width="10%">';

                      while($show = mysql_fetch_array($getFurniture)){
                      //echo  ''. $show['public_name'].'' ;
                       echo '<tr class="t_row">';
                       echo '<td>' .$show['public_name']. '</td><td><input type="checkbox" /> </td>';
                       echo '</tr>';

                      }

                  echo '</table>';

              }

          ?>

Let me know if it's not working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM