hi
i am new in here and php coding.
i got the following code frm my friend for making a name, address, passout of student searching database.
<?php
// TAKE THE INFORMATION FROM FORM.
$search = $_GET['search'];
// IF THERE IS NOT A KEYWORD GIVE A MISTAKE.
if (!$search)
echo "You didn't enter a keyword."."$text Back to Search Again <a href=searchform.php>Search</a>";
else
{
echo "<td>You searched for: <strong>$search </strong></td>";
mysql_connect('sql servername','sql server username','password');
mysql_select_db('database name');
$id=@$_GET['id'];
//QUERY IS THE CODE WHICH WILL MAKE THE SEARCH IN YOUR DATABASE.
//I WROTE AN EXPLANATION ABOUT IT AFTER THE CODE.
$query="SELECT * FROM searchform WHERE MATCH(Name, Address, Pass) AGAINST('%$search%' IN BOOLEAN MODE)";
$result1 = MySQL_query($query);
if(!$result1) {
echo MySQL_error()."<br>$query<br>";
}
if(MySQL_num_rows($result1) > 0) {
echo "<table width='480' align='center' border='1' cellspacing='0' cellpadding='0'>";
while($result2 = MySQL_fetch_array($result1)) {
//A short description from category.
$description = $result2['category'];
$searchPosition = strpos($description, $search);
$shortDescription = substr($description, $searchPosition, 150);
// I added a link to results which will send the user to your display page.
echo "<tr><td>Name</td><td>Address</td><td>Pass</td></tr>";
echo "<tr><td>{$result2['Name']}</td><td>{$result2['Address']}</td><td>{$result2['Pass']}</td></tr>";
}
echo "</table>";
}else {
echo "No Results were found.<br>"."$text Back to Search Again <a href=searchform.php>Search</a>";
}echo "<br>";
}
?>
every thing is working fine as i wanted.
my database structure is below
|NAME||ADDRESS||YEAR|
|ABC|abc|1980|
|XYZ||xyz||1980|
but there is a small problem of showing the output result.
when i search with 1980
it show 4 column
1st column is showing NAME, ADDRESS, YEAR
2nd column is showing |ABC|abc|1980|
again
3rd column is showing NAME, ADDRESS, YEAR
4th column is showing |XYZ||xyz||1980|
how i solve to not showing every column the NAME, ADDRESS, YEAR (3rd column)