How can I add a table around my code. I am new to php and I am woring on an assignment for Uni.

When I try to add the table tags the layout gets messed up. Can some please help?

<form action="gradebook3.php" method="post">
  <H4>Exam and Coursework Marks and Comments for 
HTML;
  print $line['firstname']." ".$line['surname']." (#".$line['upn'].") in set ".$line['english_set'];
  print "</h4>  <table width=\"100%\" border=\"0\" cellpadding=\"5\"><tr><td class=\"form_labels\">";
  print "Exam Mark &nbsp; &nbsp; &nbsp; &nbsp;";
  print "<input type='text' name='exam_mark' size='3' ";
  print 'value="'.$line['english_exam1_mark'].'"><br><br>';  
  print 'Exam Comments <br><textarea name="exam_comment" cols="51" rows="5">';
  print $line['english_exam1_comment']."</textarea>";
  print '<br><br>';
  print "Coursework mark:&nbsp;&nbsp;&nbsp;\n<input type='text' name='cw_mark' size='3' ";
  print 'value="'.$line['english_cw1_mark'].'"><br><br>';  
  print 'Coursework Comments: </br><textarea name="cw_comment" cols="51" rows="5">';
  print $line['english_cw1_comment']."</textarea> </br></br>";
  print "Poetry &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <select name='poetry'>,<option value='No Commendation'>No Commendation</option> <option value='Commendation Awarded'>Commendation Awarded</option>";
  print "</select><br><br>";  
  print "Creative Writing &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name='creative'>,<option value='No Commendation'>No Commendation</option> <option value='Commendation Awarded'>Commendation Awarded</option>";
  print "</select><br><br>"; 
  print "Literary Interpretation &nbsp;&nbsp;<select name='lit_int'>,<option value='No Commendation'>No Commendation</option> <option value='Commendation Awarded'>Commendation Awarded</option>";
  print "</select><br><br>"; 
   print 'Overall Comment </br><textarea name="overallcomment" cols="51" rows="5">';
  print $line['overall_comment']."</textarea> <br>";
  print '<input type="hidden" name="stu_upn" value="';
  print $line['upn'].'"><br>';
  print '<input type="submit" value="Submit">';
  print "</form>\n<br>";

put your php statments beteen <?php and ?>

<form action="gradebook3.php" method="post">
  <H4>Exam and Coursework Marks and Comments for 
HTML;
<?php
  print $line['firstname']." ".$line['surname']." (#".$line['upn'].") in set ".$line['english_set']; ?>
 </h4>  <table width="100%" border="0" cellpadding="5"><tr><td class="form_labels">
Exam Mark &nbsp; &nbsp; &nbsp; &nbsp;
 <input type='text' name='exam_mark' size='3' 
 value="<?php print $line['english_exam1_mark'];?>"><br><br>
Member Avatar for diafol

This html is a mess. </br> does not exist. Also, you have <br> and &nbsp; all over the place. Learn basic CSS - this means you can use clean HTML as opposed to padding it out. As you've mixed html and php, how about using heredoc syntax?

echo <<<HD
<form action="gradebook3.php" method="post">
  <h4>Exam and Coursework Marks and Comments for HTML; {$line['firstname']} {$line['surname']} (#{$line['upn']}) in set {$line['english_set']}</h4>  
  <table width="100%" border="0" cellpadding="5"><tr><td class="form_labels">Exam Mark &nbsp; &nbsp; &nbsp; &nbsp;<input type="text" name="exam_mark" size="3" value="{$line['english_exam1_mark']}" />
  <br /><br /> 
  Exam Comments <br />
  <textarea name="exam_comment" cols="51" rows="5">{$line['english_exam1_comment']}</textarea>
  <br /><br />
  Coursework mark:&nbsp;&nbsp;&nbsp;
  <input type="text" name="cw_mark" size="3" value="{$line['english_cw1_mark']}" />
  <br /><br />
  Coursework Comments: <br />
  <textarea name="cw_comment" cols="51" rows="5">{$line['english_cw1_comment']}</textarea>
  <br /><br />
  Poetry &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <select name="poetry">
  	<option value='No Commendation'>No Commendation</option>
	<option value='Commendation Awarded'>Commendation Awarded</option>
  </select>
  <br />
  <br />  
  Creative Writing &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <select name="creative">
  	<option value="No Commendation">No Commendation</option>
	<option value="Commendation Awarded">Commendation Awarded</option>
  </select><br /><br /> 
  Literary Interpretation &nbsp;&nbsp;
  <select name="lit_int">
     <option value="No Commendation">No Commendation</option>
	 <option value="Commendation Awarded">Commendation Awarded</option>
  </select>
  <br /><br /> 
  Overall Comment
  <br />
  <textarea name="overallcomment" cols="51" rows="5">{$line['overall_comment']}</textarea>
  <br />
  <input type="hidden" name="stu_upn" value="{$line['upn']}" />
  <br />
  <input type="submit" value="Submit" />
</form>
<br />
HD;

I've cleaned this as much as I could, but there may still be an error or two.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.