search database with php

niahossain

New Member
Messages
16
Reaction score
0
Points
0
this page http://www.bdinfo.exofire.net/bds.html containes 2 search forms. i want them to search an access database. Someone told me that I should put the form action as, form action="search.php". But then I don't what to write in search.php. Can someone please guide me on how to go about it ? I don't know php, except for the basic things that I've picked up reading tutorials. However, I'm not a slow learner, if someone would give me the steps I should follow and a template or a sample php file that searches a database, I'm sure I can do it.

From what I've gathered so far, the first thing I'm supposed to make a connection to my database in the search.php...I don't know how to do this, and neither do I kno what to do afterwards. :( I need this done within a day or 2, please help me !
 

ShannenName

New Member
Messages
5
Reaction score
0
Points
0
Code:
mysql_connect('localhost', 'mysql_user', 'mysql_password');
To make the connection to the database then the basic code should be
Code:
mysql_query("SELECT * FROM [B]table[/B] WHERE [B]table_name[/B] LIKE ('%{$_GET['[B][I]search_name'[/I][/B]]}%')",$c);
As for the actual search page put this somewhere.
Code:
<form action='[B]search.php[/B]' method='get'><input type='text' name='[B][I]search_name[/I][/B]' /><br /><input type='submit' value='Search' /></form>
 

niahossain

New Member
Messages
16
Reaction score
0
Points
0
thank you ! but i keep reading abouy MySQL, but i don't how to use that. I read that php can also connect to databases made with MS Access. Is that true ? If so, how will I make the connection ??

And in my form, there are no textboxes, but pulldown menus ? this is the html code of my form :

Code:
 <form method="POST" action="search.php">  
<p>
  <select size="1" name="D1">
  <option>Almas</option>
  <option>Nandan</option>
  <option>Etc</option>
  </select><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>

so where do i put in, name="search_name" ???
 
Top