Table recreates within iteself

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Table recreates within iteself

Post by evilmonkey »

Hello. I have a PHP script that basically says that while there is data bieng pulled from a database, create a table for each row and display it. The first result works fine. The second result created a table INSIDE the first table. The third table is created inside the second table, etc. That is not cool, and I don't like the way it looks. However, I can't seem to fix it. Here's the code, help is really appreciated.

Code: Select all

<?php
      $idd = $_GET['id'];
      //pull out user comment and diplay them
      $comments = "SELECT * FROM comments WHERE picid='$idd'";
      $commentres = mysql_query ($comments, $db);
      while ($roww = mysql_fetch_assoc ($commentres))
      {
?>
      <p></p>
      <table width="75%" height="142" border="4" cellpadding="0">
        <tr> 
          <td bordercolor="#FFFFFF" bgcolor="#707070"><font size="2" face="Modern"> 
            <strong> User: </strong><?php echo $roww['poster']; ?> <strong> Date: 
            </strong><?php echo $roww['date']; ?></font><br> </td>
        </tr>
        <tr> 
          <td height="97" bgcolor="#A8A8A8"><font size="2" face="Modern"> 
            <p><strong>Comment:</strong> <?php echo $roww['comment']; }?></p>
            </font> <p>&nbsp;</p>
            <p>&nbsp;</p></td>
        </tr>
      </table>
      <?php
	  if ($_SESSION['auth']===true) {
	  ?>
	  <form name="form1" method="post" action="comment.php">
        <p>Comment:<br>
          <textarea name="comment" cols="60" rows="6" id="comment"></textarea>
          <br>
          <input name="picid" type="hidden" id="picid2" value="<?php echo $idd; ?>">
          <input type="submit" name="Submit" value="Comment!">
        </p>
      </form>
	  <?php } else { echo "You must login to comment"; } ?> </td>
  </tr>
</table>
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

in your code you are displaying a </tr></table> at the end, remove that, and see what happens :)
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Alright, I fixed the problem (with some help). Turns out I close my php whle() brace before I close the </table> tag. D'OH!

Thanks for the reply.
Post Reply