Jump to content

Table


dudejma

Recommended Posts

Hey, I have this table and it always comes out weird. I can't get it to fix no matter how many width's I put in it. It keeps putting the input fields way too far to the right. Anyone know why? Thanks!

 

<table border="0" cellpadding="2" cellspacing="0">
  <th><font color="red">Pilot Information (all fields are required)</font></th>
  </tr>
  <tr>
  <td><hr width="500px" /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td><b>First Name: </b></td>
  <td><input type="text" length="15" value="<?php echo $fname; ?>" name="pilotid" /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td><b>Last Name: </b></td>
  <td><input type="text" length="15" value="<?php echo $lname; ?>" name="password" /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <td><b>Email: </b></td>
  <td><input type="text" length="15" value="<?php echo $email; ?>" name="email" /></td>
  </form>
  <tr>
  <tr>
  <td><br /></td>
  </tr>
  <td><b>Password: </b></td>
  <td><input type="text" length="15" value="<?php echo $password; ?>" name="password" /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td><b>Hub: </b></td>
  <td><select name="hub">
  <option value="1" <?php if ($_POST['hub'] == '1') echo 'selected="selected"'; ?>>Chicago O'Hare</option>
  <option value="2" <?php if ($_POST['hub'] == '2') echo 'selected="selected"'; ?>>Dallas Fort/Worth</option>
  <option value="3" <?php if ($_POST['hub'] == '3') echo 'selected="selected"'; ?>>John F. Kennedy</option>
  <option value="4" <?php if ($_POST['hub'] == '4') echo 'selected="selected"'; ?>>Los Angeles</option>
  <option value="5" <?php if ($_POST['hub'] == '5') echo 'selected="selected"'; ?>>Miami</option>
  </select></td>
  </tr>
  <tr>
  <td><b>Birth Date: </b></td>
  <td><select name="dobm">
    <option value="0" <?php if ($_POST['dobm'] == '0') echo 'selected="selected"'; ?>>Month</option>
    <option value="1" <?php if ($_POST['dobm'] == '1') echo 'selected="selected"'; ?>>January</option>
    <option value="2" <?php if ($_POST['dobm'] == '2') echo 'selected="selected"'; ?>>Febuary</option>
    <option value="3" <?php if ($_POST['dobm'] == '3') echo 'selected="selected"'; ?>>March</option>
    <option value="4" <?php if ($_POST['dobm'] == '4') echo 'selected="selected"'; ?>>April</option>
    <option value="5" <?php if ($_POST['dobm'] == '5') echo 'selected="selected"'; ?>>May</option>
    <option value="6" <?php if ($_POST['dobm'] == '6') echo 'selected="selected"'; ?>>June</option>
    <option value="7" <?php if ($_POST['dobm'] == '7') echo 'selected="selected"'; ?>>July</option>
    <option value="8" <?php if ($_POST['dobm'] == '8') echo 'selected="selected"'; ?>>August</option>
    <option value="9" <?php if ($_POST['dobm'] == '9') echo 'selected="selected"'; ?>>September</option>
    <option value="10" <?php if ($_POST['dobm'] == '10') echo 'selected="selected"'; ?>>October</option>
    <option value="11" <?php if ($_POST['dobm'] == '11') echo 'selected="selected"'; ?>>November</option>
    <option value="12" <?php if ($_POST['dobm'] == '12') echo 'selected="selected"'; ?>>December</option>
</select>

<select name="dobd">
    <option value="0" <?php if ($_POST['dobd'] == '0') echo 'selected="selected"'; ?>>Day</option>
    <option value="1" <?php if ($_POST['dobd'] == '1') echo 'selected="selected"'; ?>>1</option>
    <option value="2" <?php if ($_POST['dobd'] == '2') echo 'selected="selected"'; ?>>2</option>
    <option value="3" <?php if ($_POST['dobd'] == '3') echo 'selected="selected"'; ?>>3</option>
    <option value="4" <?php if ($_POST['dobd'] == '4') echo 'selected="selected"'; ?>>4</option>
    <option value="5" <?php if ($_POST['dobd'] == '5') echo 'selected="selected"'; ?>>5</option>
    <option value="6" <?php if ($_POST['dobd'] == '6') echo 'selected="selected"'; ?>>6</option>
    <option value="7" <?php if ($_POST['dobd'] == '7') echo 'selected="selected"'; ?>>7</option>
    <option value="8" <?php if ($_POST['dobd'] == '8') echo 'selected="selected"'; ?>>8</option>
    <option value="9" <?php if ($_POST['dobd'] == '9') echo 'selected="selected"'; ?>>9</option>
    <option value="10" <?php if ($_POST['dobd'] == '10') echo 'selected="selected"'; ?>>10</option>
    <option value="11" <?php if ($_POST['dobd'] == '11') echo 'selected="selected"'; ?>>11</option>
    <option value="12" <?php if ($_POST['dobd'] == '12') echo 'selected="selected"'; ?>>12</option>
    <option value="13" <?php if ($_POST['dobd'] == '13') echo 'selected="selected"'; ?>>13</option>
    <option value="14" <?php if ($_POST['dobd'] == '14') echo 'selected="selected"'; ?>>14</option>
    <option value="15" <?php if ($_POST['dobd'] == '15') echo 'selected="selected"'; ?>>15</option>
    <option value="16" <?php if ($_POST['dobd'] == '16') echo 'selected="selected"'; ?>>16</option>
    <option value="17" <?php if ($_POST['dobd'] == '17') echo 'selected="selected"'; ?>>17</option>
    <option value="18" <?php if ($_POST['dobd'] == '18') echo 'selected="selected"'; ?>>18</option>
    <option value="19" <?php if ($_POST['dobd'] == '19') echo 'selected="selected"'; ?>>19</option>
    <option value="20" <?php if ($_POST['dobd'] == '20') echo 'selected="selected"'; ?>>20</option>
    <option value="21" <?php if ($_POST['dobd'] == '21') echo 'selected="selected"'; ?>>21</option>
    <option value="22" <?php if ($_POST['dobd'] == '22') echo 'selected="selected"'; ?>>22</option>
    <option value="23" <?php if ($_POST['dobd'] == '23') echo 'selected="selected"'; ?>>23</option>
    <option value="24" <?php if ($_POST['dobd'] == '24') echo 'selected="selected"'; ?>>24</option>
    <option value="25" <?php if ($_POST['dobd'] == '25') echo 'selected="selected"'; ?>>25</option>
    <option value="26" <?php if ($_POST['dobd'] == '26') echo 'selected="selected"'; ?>>26</option>
    <option value="27" <?php if ($_POST['dobd'] == '27') echo 'selected="selected"'; ?>>27</option>
    <option value="28" <?php if ($_POST['dobd'] == '28') echo 'selected="selected"'; ?>>28</option>
    <option value="29" <?php if ($_POST['dobd'] == '29') echo 'selected="selected"'; ?>>29</option>
    <option value="30" <?php if ($_POST['dobd'] == '30') echo 'selected="selected"'; ?>>30</option>
    <option value="31" <?php if ($_POST['dobd'] == '31') echo 'selected="selected"'; ?>>31</option>
</select>

<select name="doby">
    <option value="0" <?php if ($_POST['doby'] == '0') echo 'selected="selected"'; ?>>Year</option>
    <option value="2011" <?php if ($_POST['doby'] == '2011') echo 'selected="selected"'; ?>>2011</option>
    <option value="2010"<?php if ($_POST['doby'] == '2010') echo 'selected="selected"'; ?>>2010</option>
    <option value="2009"<?php if ($_POST['doby'] == '2009') echo 'selected="selected"'; ?>>2009</option>
    <option value="2008"<?php if ($_POST['doby'] == '2008') echo 'selected="selected"'; ?>>2008</option>
    <option value="2007"<?php if ($_POST['doby'] == '2007') echo 'selected="selected"'; ?>>2007</option>
    <option value="2006"<?php if ($_POST['doby'] == '2006') echo 'selected="selected"'; ?>>2006</option>
    <option value="2005"<?php if ($_POST['doby'] == '2005') echo 'selected="selected"'; ?>>2005</option>
    <option value="2004"<?php if ($_POST['doby'] == '2004') echo 'selected="selected"'; ?>>2004</option>
    <option value="2003"<?php if ($_POST['doby'] == '2003') echo 'selected="selected"'; ?>>2003</option>
    <option value="2002"<?php if ($_POST['doby'] == '2002') echo 'selected="selected"'; ?>>2002</option>
    <option value="2001"<?php if ($_POST['doby'] == '2001') echo 'selected="selected"'; ?>>2001</option>
    <option value="2000"<?php if ($_POST['doby'] == '2000') echo 'selected="selected"'; ?>>2000</option>
    <option value="1999"<?php if ($_POST['doby'] == '1999') echo 'selected="selected"'; ?>>1999</option>
    <option value="1998"<?php if ($_POST['doby'] == '1998') echo 'selected="selected"'; ?>>1998</option>
    <option value="1997"<?php if ($_POST['doby'] == '1997') echo 'selected="selected"'; ?>>1997</option>
    <option value="1996"<?php if ($_POST['doby'] == '1996') echo 'selected="selected"'; ?>>1996</option>
    <option value="1995"<?php if ($_POST['doby'] == '1995') echo 'selected="selected"'; ?>>1995</option>
    <option value="1994"<?php if ($_POST['doby'] == '1994') echo 'selected="selected"'; ?>>1994</option>
    <option value="1993"<?php if ($_POST['doby'] == '1993') echo 'selected="selected"'; ?>>1993</option>
    <option value="1992"<?php if ($_POST['doby'] == '1992') echo 'selected="selected"'; ?>>1992</option>
    <option value="1991"<?php if ($_POST['doby'] == '1991') echo 'selected="selected"'; ?>>1991</option>
    <option value="1990"<?php if ($_POST['doby'] == '1990') echo 'selected="selected"'; ?>>1990</option>
    <option value="1989"<?php if ($_POST['doby'] == '1989') echo 'selected="selected"'; ?>>1989</option>
    <option value="1988"<?php if ($_POST['doby'] == '1988') echo 'selected="selected"'; ?>>1988</option>
    <option value="1987"<?php if ($_POST['doby'] == '1987') echo 'selected="selected"'; ?>>1987</option>
    <option value="1986"<?php if ($_POST['doby'] == '1986') echo 'selected="selected"'; ?>>1986</option>
    <option value="1985"<?php if ($_POST['doby'] == '1985') echo 'selected="selected"'; ?>>1985</option>
    <option value="1984"<?php if ($_POST['doby'] == '1984') echo 'selected="selected"'; ?>>1984</option>
    <option value="1983"<?php if ($_POST['doby'] == '1983') echo 'selected="selected"'; ?>>1983</option>
    <option value="1982"<?php if ($_POST['doby'] == '1982') echo 'selected="selected"'; ?>>1982</option>
    <option value="1981"<?php if ($_POST['doby'] == '1981') echo 'selected="selected"'; ?>>1981</option>
    <option value="1980"<?php if ($_POST['doby'] == '1980') echo 'selected="selected"'; ?>>1980</option>
    <option value="1979"<?php if ($_POST['doby'] == '1979') echo 'selected="selected"'; ?>>1979</option>
    <option value="1978"<?php if ($_POST['doby'] == '1978') echo 'selected="selected"'; ?>>1978</option>
    <option value="1977"<?php if ($_POST['doby'] == '1977') echo 'selected="selected"'; ?>>1977</option>
    <option value="1976"<?php if ($_POST['doby'] == '1976') echo 'selected="selected"'; ?>>1976</option>
    <option value="1975"<?php if ($_POST['doby'] == '1975') echo 'selected="selected"'; ?>>1975</option>
    <option value="1974"<?php if ($_POST['doby'] == '1974') echo 'selected="selected"'; ?>>1974</option>
    <option value="1973"<?php if ($_POST['doby'] == '1973') echo 'selected="selected"'; ?>>1973</option>
    <option value="1972"<?php if ($_POST['doby'] == '1972') echo 'selected="selected"'; ?>>1972</option>
    <option value="1971"<?php if ($_POST['doby'] == '1971') echo 'selected="selected"'; ?>>1971</option>
    <option value="1970"<?php if ($_POST['doby'] == '1970') echo 'selected="selected"'; ?>>1970</option>
    <option value="1969"<?php if ($_POST['doby'] == '1969') echo 'selected="selected"'; ?>>1969</option>
    <option value="1968"<?php if ($_POST['doby'] == '1968') echo 'selected="selected"'; ?>>1968</option>
    <option value="1967"<?php if ($_POST['doby'] == '1967') echo 'selected="selected"'; ?>>1967</option>
    <option value="1966"<?php if ($_POST['doby'] == '1966') echo 'selected="selected"'; ?>>1966</option>
    <option value="1965"<?php if ($_POST['doby'] == '1965') echo 'selected="selected"'; ?>>1965</option>
    <option value="1964"<?php if ($_POST['doby'] == '1964') echo 'selected="selected"'; ?>>1964</option>
    <option value="1963"<?php if ($_POST['doby'] == '1963') echo 'selected="selected"'; ?>>1963</option>
    <option value="1962"<?php if ($_POST['doby'] == '1962') echo 'selected="selected"'; ?>>1962</option>
    <option value="1961"<?php if ($_POST['doby'] == '1961') echo 'selected="selected"'; ?>>1961</option>
    <option value="1960"<?php if ($_POST['doby'] == '1960') echo 'selected="selected"'; ?>>1960</option>
    <option value="1959"<?php if ($_POST['doby'] == '1959') echo 'selected="selected"'; ?>>1959</option>
    <option value="1958"<?php if ($_POST['doby'] == '1958') echo 'selected="selected"'; ?>>1958</option>
    <option value="1957"<?php if ($_POST['doby'] == '1957') echo 'selected="selected"'; ?>>1957</option>
    <option value="1956"<?php if ($_POST['doby'] == '1956') echo 'selected="selected"'; ?>>1956</option>
    <option value="1955"<?php if ($_POST['doby'] == '1955') echo 'selected="selected"'; ?>>1955</option>
    <option value="1954"<?php if ($_POST['doby'] == '1954') echo 'selected="selected"'; ?>>1954</option>
    <option value="1953"<?php if ($_POST['doby'] == '1953') echo 'selected="selected"'; ?>>1953</option>
    <option value="1952"<?php if ($_POST['doby'] == '1952') echo 'selected="selected"'; ?>>1952</option>
    <option value="1951"<?php if ($_POST['doby'] == '1951') echo 'selected="selected"'; ?>>1951</option>
    <option value="1950"<?php if ($_POST['doby'] == '1950') echo 'selected="selected"'; ?>>1950</option>
  </select>
  <tr>
  <td><b>VATSIM ID: </b></td>
  <td><input type="text" size="15" value="<?php echo $vatsim; ?>" name="vatsim"? /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <th><font color="blue">Transfer Information (if applicable)</font></th>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td><b>Hours: </b></td>
  <td><input type="text" size="15" value="<?php echo $transferHours; ?>" name="transferHours" /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td><b>Verification Link (roster): </b></td>
  <td><input type="text" size="15" value="<?php echo $transferLink; ?>" name="transferLink" /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td><hr width="500px" /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td><b>Old Pilot ID: </b></td>
  <td><input type="text" size="15" value="<?php echo $oldPID; ?>" name="oldPID"  /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td>I agree to the terms and conditions.</td>
  <td><input type="checkbox" name="agree" value="agree" /></td>
  </tr>
  <tr>
  <td><br /></td>
  </tr>
  <tr>
  <td></td>
  <td><center><input type="submit" value="Login" name="submit" class="myButton" /></center></td>
  </tr>
  </table>
  </form>

Link to comment
Share on other sites

what I like to do when I am having trouble with tables is to set the <td>'s to a background color so I can see how they are acting, the act accordingly....your <hr> width's will definitely push everything else to the right

Link to comment
Share on other sites

I've never worked with <hr>'s before. I finally found them and was like, HEY! Line, in HTML. Coooool! But I didn't know it'd do this. And it' looks weird short. I finally figured it out, I was just thinking, what in the world could be pushing it over so far and found that the <hr>s were the only thing. Thanks AyKay! You're just a life saver.(: Haha.

Link to comment
Share on other sites

There's no opening <form> tag in the code you posted.

 

You're missing the very first <tr> tag.

 

Each <tr> needs to have the same number of <td>'s in it, so in each <tr> that contains only one <td>, you need to change it to <td colspan="2">

 

There's a seemingly random </form> tag in the markup after the email field, followed immediately by a duplicated set of <tr><tr> tags.

 

Missing the <tr> tag before the password field.

 

Actually, there are too many tag mismatch errors to keep listing them.

 

You have a lot of unnecessary code to generate the <select> fields, too.

 

Since I'm in a good mood, and I happen to use VATSIM, I went through the code, cleaned it up, and made the select fields a bit more manageable by generating them dynamically.

 

<table border="0" cellpadding="2" cellspacing="0">
<tr>
<th colspan="2"><font color="red">Pilot Information (all fields are required)</font></th>
</tr>

<tr>
<td colspan="2"><hr width="500px" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td><b>First Name: </b></td>
<td><input type="text" length="15" value="<?php echo $fname; ?>" name="pilotid" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td><b>Last Name: </b></td>
<td><input type="text" length="15" value="<?php echo $lname; ?>" name="password" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td><b>Email: </b></td>
<td><input type="text" length="15" value="<?php echo $email; ?>" name="email" /></td>
</form>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td ><b>Password: </b></td>
<td><input type="text" length="15" value="<?php echo $password; ?>" name="password" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td><b>Hub: </b></td>
<td><select name="hub">
<?php
$hubs = array(1 => 'Chicago O\'Hare', 'Dallas/Fort Worth', 'John F. Kennedy', 'Los Angeles', 'Miami');
$sel = ' selected="selected"';
foreach( $hubs as $k => $v ) {
   echo "<option value =\"$k\"";
   echo (!empty( $_POST['hub'] ) && $_POST['hub'] = $k) ? $sel : '';
   echo ">$v</option>\n";
}
?>
</select></td>
</tr>

<tr>
<td><b>Birth Date: </b></td>
<td><select name="dobm">

<?php
$months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
foreach( $months as $k => $v ) {
   echo "<option value =\"$k\"";
   echo (!empty( $_POST['dobm'] ) && $_POST['dobm'] = $k) ? $sel : '';
   echo ">$v</option>\n";
}
?>
</select>

<select name="dobd">
<?php
$days = range( 1, 31 );
foreach( $days as $k => $v ) {
   echo "<option value =\"$k\"";
   echo (!empty( $_POST['dobd'] ) && $_POST['dobd'] = $k) ? $sel : '';
   echo ">$v</option>\n";
}
?>
</select>

<select name="doby">
<?php
$now = date('Y');
$start = $now - 100;
$years = range( $now, $start );
foreach( $years as $k => $v ) {
   echo "<option value =\"$k\"";
   echo (!empty( $_POST['doby'] ) && $_POST['doby'] = $k) ? $sel : '';
   echo ">$v</option>\n";
}
?>
</select></td>

<tr>
<td><b>VATSIM ID: </b></td>
<td><input type="text" size="15" value="<?php echo $vatsim; ?>" name="vatsim" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<th colspan="2"><font color="blue">Transfer Information (if applicable)</font></th>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td><b>Hours: </b></td>
<td><input type="text" size="15" value="<?php echo $transferHours; ?>" name="transferHours" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td><b>Verification Link (roster): </b></td>
<td><input type="text" size="15" value="<?php echo $transferLink; ?>" name="transferLink" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td colspan="2"><hr width="500px" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td><b>Old Pilot ID: </b></td>
<td><input type="text" size="15" value="<?php echo $oldPID; ?>" name="oldPID"  /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td>I agree to the terms and conditions.</td>
<td><input type="checkbox" name="agree" value="agree" /></td>
</tr>

<tr>
<td colspan="2"><br /></td>
</tr>

<tr>
<td colspan="2"><center><input type="submit" value="Login" name="submit" class="myButton" /></center></td>
</tr>

</table>
</form>

 

Changes I did not make:

You need to check if a variable exists before attempting to access its value, so you should do so in the value= attributes of the form fields before trying to echo them

value="<?php echo isset( $fname ) ? $fname : ''; ?>"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.