MySQL Forums
Forum List  »  PHP

Display search results in table
Posted by: Jo Miles-Seely
Date: April 05, 2010 02:18PM

I have created a script that searches all 3 fields of a MySQL database and returns the results of 2 of the columns on a web page. I want the rows returned to display in a form with the columns of each row side-by-side. I've never done this before. Samples I find on the web are confusing because I'm not finding a script that is similar to how I've written mine. Can someone please help me take what I've got and create what I want? I understand that I need to create an html table, but, I don't know where to put it or how to get my data into it. Below is my script. Thanks.

<title>Title Goes Here</title>
<h2>Heading Goes Here</h2>

$search_term = $_POST['searchterm'];

$dbc = mysqli_connect('localhost', 'username', 'password', 'database') or die ('Cannot connect to database');
$query = "SELECT * FROM subject WHERE title LIKE '%$search_term%' || subject LIKE '%$search_term%' || keyword LIKE '%$search_term%'";

$result = mysqli_query($dbc, $query) or die('Cannot execute query');

echo 'Your search term ' . $search_term . 'produced the following results: <br /><br />';

while ($i < $num) {

echo $title;
echo $subject;



Options: ReplyQuote

Written By
Display search results in table
April 05, 2010 02:18PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.