Display php result after html -


i have form people can search database user. when search user , click submit, they're re-directed different page , results displayed.

my issue results being displayed before required html tags - here's example of page looks through inspect element:

"bobby123   " <!doctype html> <html> <body> </body> </html> 

how display results after required html tags? how set "set place" results displayed?

here's code:

<?php if(isset($_post['submit'])) {     $term = $_post['search'];     $searchuser = $stmt = $con->prepare("select * users username :term");     $stmt->bindvalue(':term', '%'.$term.'%');     $stmt->execute();     if($searchuser->rowcount() > 0) {         while($row = $searchuser->fetch()){             $name = $row['username'];             echo $name;         }     }else{         echo 'no results';     } } ?>  <form method="post" action="results.php"> <input name="search" type="search"> <input type="submit" name="submit"> </form> 

the code on results.php is:

<!doctype html> <html> <body> </html> 

if possible, not use coding javascript, jquery, or run on client side.

instead of

if($searchuser->rowcount() > 0) {     while($row = $searchuser->fetch()){     $name = $row['username'];     echo $name; }}else{     echo 'no results'; } } 

use

if($searchuser->rowcount() > 0) {     $content = "";     while($row = $searchuser->fetch()){         $content .= '<p>' . $row['username'] . '</p>';     } }else{     $content = 'no results'; } 

then, in html (where want text display)

<html> <body> <?php echo $content; ?> </body> </html> 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -