-1

I have the following code:

<?php
 require "dbconn.php";

 $register="SELECT * from register WHERE username = '". $_SESSION['username']."'";

$re = $connect->query($register);

$numrow = $re->num_rows; 

echo "<table>";
echo "<tr>";
echo"<th>Username</th>";
echo"<th>Forename</th>";
echo"<th>Surname</th>";
echo"<th>Course</th>";
echo"<th>Subject</th>";
echo"<th>Level</th>";
echo"<th>Date</th>";
echo"<th>Time</th>";
echo"</tr>";

$count = 0;
while ($count < $numrow) 
{
$row = $re->fetch_assoc();
extract($row);    
echo "<tr>";

echo "<td>";
echo $username;
echo "</td>";

echo "<td>";
echo $firstName;
echo "</td>";

echo "<td>";
echo $surname;
echo "</td>";

echo "<td>";
echo $course;
echo "</td>";

echo "<td>";
echo $subject;
echo "</td>";

echo "<td>";
echo $level;
echo "</td>";

echo "<td>";
echo $date;
echo "</td>";

echo "<td>";
echo $time;
echo "</td>";

echo "</tr>";

$count = $count + 1;
}

?>

It shows the records from the database as a form. I have the following button:

<FORM METHOD="LINK" ACTION="register.php">
<INPUT TYPE="submit" VALUE="Go back to register"></INPUT></form>

No matter what DIV I put the button in, or what CSS I give it. The button always stays ABOVE the form from the database and I cannot get it below the table.

Any ideas?

pnuts
  • 58,317
  • 11
  • 87
  • 139
David
  • 3
  • 1
  • 4
  • It would help if you posted the complete code becsause there is no indication of where the form element is in relation to the db output. A quick and dirty fix is to put the submit button in a table footer. – David Soussan Apr 01 '15 at 19:27
  • Look at this: http://stackoverflow.com/questions/11582286/form-method-link-or-a-whats-the-difference Don't think there is a method called "LINK" – Maximus2012 Apr 01 '15 at 19:28
  • The link isn't the problem and irrelevant to the question..the form is under $count = $count + 1; } and in the same div. If I put it in another div the result is still the same. Yeah that could work but was wondering if there is a nicer way – David Apr 01 '15 at 19:31
  • You *must* put `session_start()` at the top of every page your expect to use the `$_SESSION()` array. – Jay Blanchard Apr 01 '15 at 19:33
  • `` is an empty element and should not have a closing tag. I don't think that's your problem though. If the code is indeed below the ending of your PHP code, there should be no reason for it to not be below the table, unless you have some CSS you're not sharing. – Heretic Monkey Apr 01 '15 at 19:33
  • Yes I am aware of the session start. That is not the problem. I have a whole web page which I'm not going to copy and paste as it's not needed. I have only shown RELEVANT INFORMATION. But no there is no other CSS – David Apr 01 '15 at 19:36
  • I can't fit in enough 9's for *99.99999999999 times out of a 100*, OP's say: *It's loaded Sam!* - @JayBlanchard – Funk Forty Niner Apr 01 '15 at 19:36
  • 1
    *Yeeehaw Ralph!* @Fred-ii- – Jay Blanchard Apr 01 '15 at 19:38
  • Thanks for your useful informatiion... – David Apr 01 '15 at 19:39
  • So... put your form after the PHP? – Funk Forty Niner Apr 01 '15 at 19:44
  • ^ what do you think *Sam?* - @JayBlanchard – Funk Forty Niner Apr 01 '15 at 19:55
  • Like I said. After the PHP. In the PHP. In the DIV. Out of the DIV. It stays the same – David Apr 01 '15 at 19:59
  • You're going to need to show us the exact placement you're using it in your code then. You posted your PHP and your HTML apart from it and we've no way of knowing how it's being used. Plus, if you've any JS/Ajax to share with that piece of code; please do. – Funk Forty Niner Apr 01 '15 at 20:00
  • Plus, I don't see a closing `` tag. That'll do some nasty tricks. – Funk Forty Niner Apr 01 '15 at 20:01
  • Oh, in regards to `METHOD="LINK"` read the following http://stackoverflow.com/a/11582427/ - there is no "method=link". You either want to use `method="post"` or "get". – Funk Forty Niner Apr 01 '15 at 20:03
  • Yeah I know about the link I've changed that. But you have solved it thank you. It was because the table wasn't closed – David Apr 01 '15 at 20:09
  • Great and you're welcome David, would you like me to post that as answer then? Along about the bit for method=link. – Funk Forty Niner Apr 01 '15 at 20:12
  • 1
    Sure go for it and i'll accept it – David Apr 01 '15 at 20:15
  • It has been done David, *cheers* – Funk Forty Niner Apr 01 '15 at 20:18

1 Answers1

0

Firstly, you did not close your table with a </table> tag; it's important that you do.

Then there's METHOD="LINK" which doesn't exist and isn't a valid method.

You either want to use method="post" or method="get".

See this answer on Stack about it:

Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141