I have small doubt in PHP coding, please help me. Actually I am displaying jobs currently, after searching,the result will displayed in the same page. It is done, but the result is displaying below the content. What I have to do to display only results in that page? I want to make unavailable the previous contents.This is the code:
<html>
<head>
<title>Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h2>Job Openings</h2>
<form method="POST" action="jobopenings.php">
<input type="text" name="txt" required />
<input type="submit" name="btn" value="search" /><br/>
</form>
</body>
</html>
<?php
define('HOST', 'localhost');
define('USER', 'root');
define('PASS', '');
define('DB', '*****');
$con = mysqli_connect(HOST,USER,PASS,DB) or die("Unable to connect to db");
$selQ = "Select * from jobpostings";
$res1 = mysqli_query($con, $selQ);
while($row = mysqli_fetch_array($res1))
echo $row[3]."<br> Job Id:<b>".$row[2]."</b><br><b>".$row[1]."</b>"."
<br>"."Exp:".$row[5]."<br>"."Location:".$row[6]."<br>".$row[8]."<br><br>";
if(isset($_POST["btn"])){
$query=$_POST['txt'];
$query=htmlspecialchars($query);
$query=mysqli_real_escape_string($con,$query);
$raw_results="select * from jobpostings where (C_name like '%" .$query."%')
or (Job_title like '%".$query."%')";
$final_results=mysqli_query($con,$raw_results);
if(mysqli_num_rows($final_results)>0){
while($results=mysqli_fetch_array($final_results)){
echo "<p><b>".$results[1]."</b><br> Job Id:".$results[2]
<br>".$results[3]."</p>";
}
}
else{
echo '<b style="color:red;">No results found</b>';
}
}
?>
Thanks in advance
".$results[1]."
";` this line? – B. Desai Oct 04 '17 at 12:04Job Id:".$results[2]
".$results[3]."