PHP search

I have a view/update form…this is working well! http://205.122.20.31/Login/high-school-transmittal.php?
I need to add a search function located in a different page. I get a this error
Can’t run query because Unknown column ‘$id’ in ‘where clause’

If i place id in my search code it returns nothing?? Please help!!It’s been days:( My boss is mad :frowning: I’m hating my life!!

the search code:

$dbhost = “”;
$dbuser = “”;
$dbpass = “”;
$dbname = “”;

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (‘Error connecting to mysql’);
mysql_select_db($dbname);

if(isset($_GET[‘query’])) { $query = $_GET[‘query’]; } else { $query = “”; }
if(isset($_GET[‘type’])) { $type = $_GET[‘type’]; } else { $query = “count”; }

if($type == “count”)
{
$sql = mysql_query(“SELECT count(id)
FROM highschoolstudents
WHERE MATCH(studentname, highschool, program)
AGAINST(’$query’ IN BOOLEAN MODE)”);
$total = mysql_fetch_array($sql);
$num = $total[0];

echo $num;

}

if($type == “results”)
{
$sql = mysql_query(“SELECT URL, studentname, highschool, program
FROM highschoolstudents
WHERE MATCH(studentname, highschool, program)
AGAINST(’$query’ IN BOOLEAN MODE)”);
while($array = mysql_fetch_array($sql)) {

	$studentname = $array['studentname'];
	$highschool = $array['highschool'];
	$program = $array['program'];
	
	echo "<div class=\"url-holder\"><a href=\"" . $studentname . "\" class=\"url-title\" target=\"_blank\">" . $highschool . "</a>
<div class=\"url-desc\">" . $studentname . "</div></div>";
echo '<a href="http://205.122.20.31/Login/high-school-transmittal.php?id=$id">[full record]</a>' ;
			
}

}

mysql_close($conn);

?>

is this line here correct?
[php]if(isset($_GET[‘query’])) { $query = $_GET[‘query’]; } else { $query = “”; }
if(isset($_GET[‘type’])) { $type = $_GET[‘type’]; } else { $query = “count”; }[/php]

should the last else not be: $type = “count”; ?

Sponsor our Newsletter | Privacy Policy | Terms of Service