I have two tables in one form and a button in another form. So the two tables must be displayed first and then the button. But for me the button is displayed between the two tables. Can anyone help me??

This is my code

<form action="choirEvedit.php5" method="post">
<?php

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("centreformusic", $con);
   $res=mysql_query("select * from choirevent where ProgId='$_GET[pid]' and event_date='$_GET[dt]'") or die(mysql_error());
        echo "Events<br><br>";
        echo "<input type='hidden' name='pid' value='$_GET[pid]'>";
        echo "<table border='0' cellpadding='3' cellspacing='3' class='name'>";
        echo "<tr><th>Event Date:</th><th>Time:</th><th>Title:</th></tr>";
        while($row=mysql_fetch_array($res))
        {   
          
           echo "<tr><td><a href='choirEved.php5?pid=".$row[ProgId]."&dt=".$row[event_date]."'>".$row[event_date]."</a></td>";
           echo "<td>".$row[Time]."</td>";
           echo "<td>".$row[title]."</td></tr>"; 
        }
        echo "</table>";
  $sql=mysql_query("select * from song where ProgId='$_GET[pid]'") or die(mysql_error());
   echo "<table border='0' cellpadding='3' cellspacing='3' class='name'>";   
   $count=0;
   echo "<tr><th>S.No.</th><th>Song</th><th>Author</th>";
   while($row=mysql_fetch_array($sql))
   {
       $count=$count+1;
       echo "<tr><td><a href='choirEvSong.php5?pid=".$row[ProgId]."&sid=".$row[SongID]."'>$count</a></td>";
       echo "<td>".$row[Song]."</td>";
       echo "<td>".$row[Author]."</td></tr>";
   }
  
mysql_close($con);
?>
</form>
<form action="choirEvent1.php5" method="post">
<input type="image" src="images/back.png">
</form>

Dani AI

Generated

Short diagnosis: the PHP that prints the second table never closes that table before the script ends, so the browser treats the following form as part of the table. That makes the image-button appear between rows. was on the right track — an unclosed table or a float can create exactly this effect.

What to do (quick steps)

  • Make sure every table you open is explicitly closed before you start a new form or other block-level element.
  • Use the browser inspector (right‑click → Inspect) to view the actual DOM the browser built; if you see a <form> inside a <table> you have an unclosed tag.
  • Run the page through the W3C HTML validator to catch any other missing/incorrect tags: W3C Validator.
  • If you are using floated elements, add a clearfix or a clear element (as suggested) to push following content below floats.

Additional notes and best practices

  • Avoid keeping UI markup tangled inside many echo statements; it’s easier to spot missing tags when the HTML structure is more explicit.
  • Do not rely on input type="image" for layout — use a normal submit button or style a button with a background image so layout is predictable.
  • Security/maintenance: the code is using deprecated mysql_* functions and unescaped $_GET directly in queries. Migrate to mysqli or PDO and use prepared statements; see the PHP docs for guidance: mysqli quickstart.

Closing note: fixing the missing closing table (or validating the rendered HTML) will almost certainly move the button to after both tables.

check to see if <div style="clear:both"> or something similar works OR just make sure you have finished the table off correctly with </table>

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.