Current location: Hot Scripts Forums » Programming Languages » PHP » mysql/php search script


mysql/php search script

Reply
  #1 (permalink)  
Old 06-21-04, 05:33 PM
dawggy505 dawggy505 is offline
Newbie Coder
 
Join Date: May 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
mysql/php search script

alright, i made this php script to search through a mysql database. it is very small and the script is very easy but i am having a few problems.

i want the user to type in the value of the search (duh) and have the script find it.

the html on the first page it this:

<html>
<head><title> Search | langauges </title>
</head>
<body>
<h2> Search for a shop</h2>
<br>
<form action="resultsbyname.php" method="post">
Pleae enter the name, or part of the name of the language you are looking for:<br>
<input name="name" type="text">
<br>
<input type="submit" value="Search">
</form>

</body>
</html>

VERY basic stuff. now, the php on the results page is this:


PHP Code:

<html>
<head><title>Your Query Results</title></head>
<body>
 <h2> Search Results</h2>
 <br>
 <?
 $link 
"<a href='searchbyname.html'> Back </a>";
 if (!
name){
  echo 
"Not Foumd";
  echo 
$link;
 exit; 
 }
    
$db mysql_connect("localhost");
    
mysql_select_db("kyleprolang"$db);
    
$query "SELECT languages.language FROM languages WHERE language LIKE '%".$name."%'";
    
$result mysql_query($query);
    while (
$record mysql_fetch_assoc($result)){
 while(list(
$fieldname$fieldvalue) = each($record)){
  echo 
$fieldname.": <br>".$fieldvalue."</b><br>";
 }
 echo 
"<br>";
 }
 
?>
</body>
</html>
I know that problem in the PHP script is where it says:

PHP Code:

 $query "SELECT languages.language FROM languages WHERE language LIKE '%".$name."%'"
i don't know what to put there. i want php to search the entire database. the databse is as followed:

Name: kyleprolang

Tables:

1) Languages
2) Power

Languages:

+--------------+------------+--------------+
| Language | Difficulty | Fun_Level |
+--------------+------------+--------------+
|_________|_________|_________| }
|_________|_________|_________| }
|_________|_________|_________| values and stuff
|_________|_________|_________| }
|_________|_________|_________| }
|_________|_________|_________|



Power:

+--------------+------------+
|Number |Language|
+--------------+------------+
|_________ |________|
|_________ |________| } values and stuff

i want PHP to search through the entire database and echo the results. how would i have PHP search through the entire data base in the "$query =" line?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-22-04, 07:49 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
not sure about that.. try
PHP Code:

 $query "SELECT languages.language FROM languages WHERE language LIKE '%$name%'"
ps. fancy signature
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
cross language search script cgiwizard Script Requests 0 03-09-04 07:43 PM
Simple search script niceguyonline Script Requests 3 03-08-04 12:09 AM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM
How to integrate a search engine to my script ? Simonoff Script Requests 2 10-31-03 04:43 PM


All times are GMT -5. The time now is 12:52 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.