0

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>";
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by diafol
0

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>

Edited by pzuurveen: n/a

0

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.

Edited by diafol: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.