0

Here is what is happening.

Here is some pseudo code

echo "<table class='container'><tr class='stuff'></tr>
<form method='post' action='edit.php' name='edit'>
<tr class='setting' hidden>

... Some inputs and such go here...

<td class='checkbox'>
<input class='cancel' type='button'>
<input class='save' name='update' value='update' type='submit'>
</td></tr></form></table>";

EDIT: Here is the actual code

 <?php
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(! $conn )
    {

      die('Could not connect: ' . mysql_error());
    }
    if($_SESSION['school'] == "drl") {
        $sql = 'SELECT id, student_name, student_id, grad_year, grade, test_name, individual, team_event, member_number, team_number, captain  FROM drl';
    }
    elseif($_SESSION['school'] == "Butler Tech") {
        $sql = 'SELECT id, student_name, student_id, grad_year, grade, test_name, individual, team_event, member_number, team_number, captain  FROM butlertech';
    }
    elseif($_SESSION['school'] == "MIT") {
        $sql = 'SELECT student_name, student_id, grad_year, grade, test_name, individual, team_event, member_number, team_number, captain FROM mit';

    }
    mysql_select_db('contestants');
    $retval = mysql_query( $sql, $conn );
    if(! $retval )
    {
      die('Could not get data: ' . mysql_error());
    }
    while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
    {
        echo 
         "<table class='container'><tr class='stuff'><td hidden>{$row['id']}</td><td>{$row['student_name']}</td></input><td>{$row['student_id']}</td><td class='shcell'>{$row['grade']}</td><td>{$row['test_name']}</td><td>{$row['individual']}</td><td>{$row['team_event']}</td><td class='shcell'>{$row['team_number']}</td><td class='shcell'>{$row['captain']}</td><td class='checkbox' class='odd'>   <input class='edit' type='button'>  <input class='delete' type='button'> </td></tr>

      <tr class='setting' hidden> <form method='post' action='edit.php' name='edit'>

        <td><input type='text' name='id' value='"; echo $row['id']; echo "' hidden></input><input id='school' value='"; echo $_SESSION['school']; echo "'name='school' hidden>
        <input id='student_name' type='text' value='{$row['student_name']}' name='student_name' /></td>
        <td><input  id='student_id' type='text' value='{$row['student_id']}' name='student_id' /></td>
        <td class='shcell'><select id='grade' name='grade'>
            <option value = '7th'"; if($row['grade'] == '7'){ echo 'selected="selected"';} echo ">7th</option>
        <option value = '8th'"; if($row['grade'] == '8'){ echo 'selected="selected"';} echo ">8th</option>
        <option value = '9th'"; if($row['grade'] == '9'){ echo 'selected="selected"';} echo ">9th</option>
        <option value = '10th'"; if($row['grade'] == '10'){ echo 'selected="selected"';} echo ">10th</option>
        <option value = '11th'"; if($row['grade'] == '11'){ echo 'selected="selected"';} echo ">11th</option>
        <option value = '12th'"; if($row['grade'] == '12'){ echo 'selected="selected"';} echo ">12th</option>
      </select></td>
    <td><select class='settings' id='test_name' name='test_name'>
        <option value = 'None'"; if($row['captain'] == 'None'){ echo 'selected="selected"';} echo ">None</option>
        <option value = '(01) Fundamental Accounting'"; if($row['test_name'] == '(01) Fundamental Accounting'){ echo 'selected="selected"';} echo ">(01) Fundamental Accounting</option>
        <option value = '(02) Advanced Accounting'"; if($row['test_name'] == '(02) Advanced Accounting'){ echo 'selected="selected"';} echo ">(02) Advanced Accounting</option>
        <option value = '(04) Payroll Accounting"; if($row['test_name'] == '(04) Payroll Accounting'){ echo 'selected="selected"';} echo "'>(04) Payroll Accounting</option>
        <option value = '(12) Financial Math & Analysis'"; if($row['test_name'] == '(12) Financial Math & Analysis'){ echo 'selected="selected"';} echo ">(12) Financial Math & Analysis</option>
        <option value = '(13) Insurance Concepts'"; if($row['test_name'] == '(13) Insurance Concepts'){ echo 'selected="selected"';} echo ">(13) Insurance Concepts</option>
        <option value = '(14) Federal Income Tax Accounting'"; if($row['test_name'] == '(14) Federal Income Tax Accounting'){ echo 'selected="selected"';} echo ">(14) Federal Income Tax Accounting</option>
        <option value = '(20) Keyboarding Production'"; if($row['test_name'] == '(20) Keyboarding Production'){ echo 'selected="selected"';} echo ">(20) Keyboarding Production</option>
        <option value = '(46) Fundamentals of Web Design'"; if($row['test_name'] == '(46) Fundamentals of Web Design'){ echo 'selected="selected"';} echo ">(46) Fundamentals of Web Design</option>
        <option value = '(47) PC Servicing & Troubleshooting'"; if($row['test_name'] == '(47) PC Servicing & Troubleshooting'){ echo 'selected="selected"';} echo ">(47) PC Servicing & Troubleshooting</option>
        <option value = '(48) Computer Security'"; if($row['test_name'] == '(48) Computer Security'){ echo 'selected="selected"';} echo ">(48) Computer Security</option>
      </select></td>
    <td><select class='settings' name='individual' value='{$row['individual']}'>
        <option value = 'None'"; if($row['individual'] == 'None'){ echo 'selected="selected"';} echo ">None</option>
        <option value = '(03) Computerized Accounting'"; if($row['individual'] == '(03) Computerized Accounting'){ echo 'selected="selected"';} echo ">(03) Computerized Accounting</option>
        <option value = '(06) Fundamental Spreadsheet Applications'"; if($row['individual'] == '(06) Fundamental Spreadsheet Applications'){ echo 'selected="selected"';} echo ">(06) Fundamental Spreadsheet Applications</option>
        <option value = '(07) Advanced Spreadsheet Applications'"; if($row['individual'] == '(07) Advanced Spreadsheet Applications'){ echo 'selected="selected"';} echo ">(07) Advanced Spreadsheet Applications</option>
        <option value = '(08) Banking & Finance'"; if($row['individual'] == '(08) Banking & Finance'){ echo 'selected="selected"';} echo ">(08) Banking & Finance</option>
        <option value = '(10) Economic Research Project Individual'"; if($row['individual'] == '(10) Economic Research Project Individual'){ echo 'selected="selected"';} echo ">(10) Economic Research Project Individual</option>
        <option value = '(21) Fundamental Word Processing Skills'"; if($row['individual'] == '(21) Fundamental Word Processing Skills'){ echo 'selected="selected"';} echo ">(21) Fundamental Word Processing Skills</option>
        <option value = '(22) Advanced Word Processing Skills'"; if($row['individual'] == '(22) Advanced Word Processing Skills'){ echo 'selected="selected"';} echo ">(22) Advanced Word Processing Skills</option>
        <option value = '(31) Administrative Support Research Project Individual'"; if($row['individual'] == '(31) Administrative Support Research Project Individual'){ echo 'selected="selected"';} echo ">(31) Administrative Support Research Project Individual</option>
        <option value = '(64) Interview Skills'"; if($row['individual'] == '(64) Interview Skills'){ echo 'selected="selected"';} echo ">(64) Interview Skills</option>
        <option value = '(69) Presentation Management Individual'"; if($row['individual'] == '(69) Presentation Management Individual'){ echo 'selected="selected"';} echo ">(69) Presentation Management Individual</option>
      </select></td>
    <td><select class='settings' name='team_event' value='{$row['team_event']}'>
        <option value = 'None'"; if($row['team_event'] == 'None'){ echo 'selected="selected"';} echo ">None</option>
        <option value = '(09) Financial Analyst Team'"; if($row['team_event'] == '(09) Financial Analyst Team'){ echo 'selected="selected"';} echo ">(09) Financial Analyst Team</option>
        <option value = '(11) Economic Research Project Team'"; if($row['team_event'] == '(11) Economic Research Project Team'){ echo 'selected="selected"';} echo ">(11) Economic Research Project Team</option>
        <option value = '(30) Administrative Support Team'"; if($row['team_event'] == '(30) Administrative Support Team'){ echo 'selected="selected"';} echo ">(30) Administrative Support Team</option>
        <option value = '(50) Computer Animation Team'"; if($row['team_event'] == '(50) Computer Animation Team'){ echo 'selected="selected"';} echo ">(50) Computer Animation Team</option>
        <option value = '(51) Network Design Team'"; if($row['team_event'] == '(51) Network Design Team'){ echo 'selected="selected"';} echo ">(51) Network Design Team</option>
        <option value = '(53) Video Production Team'"; if($row['team_event'] == '(53) Video Production Team'){ echo 'selected="selected"';} echo ">(53) Video Production Team</option>
        <option value = '(55) Web Site Design Team'"; if($row['team_event'] == '(55) Web Site Design Team'){ echo 'selected="selected"';} echo ">(55) Web Site Design Team</option>
        <option value = '(57) Broadcast News Production Team'"; if($row['team_event'] == '(57) Broadcast News Production Team'){ echo 'selected="selected"';} echo ">(57) Broadcast News Production Team</option>
        <option value = '(62) Small Business Management Team'"; if($row['team_event'] == '(62) Small Business Management Team'){ echo 'selected="selected"';} echo ">(62) Small Business Management Team</option>
        <option value = '(70) Presentation Management Team'"; if($row['team_event'] == '(70) Presentation Management Team'){ echo 'selected="selected"';} echo ">(70) Presentation Management Team</option>
      </select></td>
    <td class='shcell'><input id='team_number' name='team_number'  min='1' value='{$row['team_number']}' class='number' type='number' /></td>
    <td class='shcell'><select id='captain' name='captain'>
        <option value = '-'"; if($row['captain'] == '-'){ echo 'selected="selected"';} echo ">-</option>
        <option value = 'No'"; if($row['captain'] == 'No'){ echo 'selected="selected"';} echo ">No</option>
        <option value = 'Yes'"; if($row['captain'] == 'Yes'){ echo 'selected="selected"';} echo ">Yes</option>
      </select></td>
      <td class='checkbox'>
        <input class='cancel' type='button'>
        <input class='save' name='update' value='update' type='submit'></td></form></tr></table>";}

    mysql_close($conn);
?>

Everything works as intended, except for the form part. As you can see in the picture, the form is being echoed before everything else. What I want is for <tr class='setting' hidden></tr> to be inside the form.

Leigh
  • 28,765
  • 10
  • 55
  • 103
Tyler
  • 15
  • 1
  • 1
  • 5
  • 1
    Your pseudocode won't do that. Could you add your real code? – andrewsi Sep 02 '13 at 00:08
  • Pseudo code doesn't help. Please post the actual code – Sterling Archer Sep 02 '13 at 00:08
  • 1
    A DOM inspector is no replacement for viewing the actual source. What you're seeing is the browser's interpretation of your malformed HTML – Phil Sep 02 '13 at 00:11
  • In your code, you've got your `` before the opening form tag. Why not swap those two around? Or move the `` to immediately before the `` tag, and the `` to after the `
    `?
    – andrewsi Sep 02 '13 at 00:17
  • It seems moving the `
    ` to immediately before the `` tag, has fixed my problem. Thank you all!
    – Tyler Sep 02 '13 at 00:23

3 Answers3

3

Change your code so that <form> is before <table> not inside it:

echo "<form method='post' action='edit.php' name='edit'>
<table class='container'>
    <tr class='stuff'></tr>

        <tr class='setting' hidden>

        ... Some inputs and such go here...

        <td class='checkbox'>
        <input class='cancel' type='button'>
        <input class='save' name='update' value='update' type='submit'>
        </td></tr>
    </table>
</form>";
Charaf JRA
  • 8,249
  • 1
  • 34
  • 44
3

When you're using <form> with <table> you need to either put the <form> tags completely outside the <table>, or have the entire <form> inside one <td>. Any other structure breaks the syntax of the <table> and will be ignored by the browser, or rendered incorrectly.

Valid HTML:

<form>
  <table>
    <tr>
      <td>
         <input name="data" type="text">
         <input name="moredata" type="text">
      </td>

      <td>
         <input name="yetmoredata" type="text">
      </td>
    </tr>
  </table>
</form>

Alternatively

  <table>
    <tr>
      <td>
         <form>
         <input name="data" type="text">
         <input name="moredata" type="text">
         </form>
      </td>
    </tr>
  </table>
0

Code you place in between table rows without specificing a cell to contain it, will end messed up, probably pushed outside the table body. Its no place to put anything.

You can either put the form inside a cell or put the whole table inside the form. This thing you are doing makes no sense, thats why the browser is ignoring it.

If the form is ruining your formatting, create a CSS style for form { padding: 0; margin: 0 }

Havenard
  • 27,022
  • 5
  • 36
  • 62