954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP coding for a Search Field on Drupal

hi im working on a search field in drupal for a system that maintains student information.
i have one interface that has the search student info box and the other which is search results
i wrote some php code to search the and there are no errors yet still its not working. when i press find it simply redirects it to front page of drupal.
without any results being showed.
i will show the code below, please tell me what to do..

SEARCH

Name:
Course:

ALLCTHE
Date of Course:

20092010JanFeb
Completed Successfully:

YES NO ALL

Payments Made:

YES NO ALL


rukshilag
Junior Poster
101 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

Try to do the following way:

$sql="SELECT * FROM course_participant WHERE name like '%".$searchname."%'"; //Select Query
$result = mysql_query($sql); //execute the query and get the result
if(mysql_num_rows($result) > 0) //If there is a result, display it
{
	echo "The search results are:";
	while ($row = mysql_fetch_assoc($result)) {
		echo $row['name']."";
	}
}
else // If no result found
{
echo "No result found!"; //Display the "not found" mesasge
}
as.bhanuprakash
Junior Poster
109 posts since Dec 2009
Reputation Points: 16
Solved Threads: 21
 

http://localhost/sdc/?q=node/2 - that is wht i put as the form action.. php code seems ok...

rukshilag
Junior Poster
101 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: