SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Searching!!!

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2000
    Location
    Location:
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm trying to devise a form which will allow users to search for all the data within a database which I have just created.

    The name of the database is 'Music_groups'.

    This database is full of different categories of music groups which are all contained within a single table called 'groups'.

    This table holds the names of music groups in the following categories;

    Rap
    Jazz
    Chior
    Barbershop

    This table is formed of the following coloumns;

    Category
    Group_name
    Contact_name
    Address
    City
    Telephone
    E_mail
    Information


    In basic terms, this form has to allow users to;

    1) Search for any group within the table
    2) List all the groups in the table according to the columns 'Category' and 'City'.

    (I chose 'Category' and 'City' because they are the most important fields which users can easily identify with).

    I'm a beginner when it comes to php and I'm really not sure how to make this happen. Can anyone please show me a script which can perform such searches on the database according to whatever columns the user specifies???

    I hope I have made sense!

    Thanx very much,


    Koncise.

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, short of writing an actual functional script, I can explain a tiny bit of the logic behind it.

    It's a simple SELECT command...you have a search box...something like this:

    Code:
    <input type="text" name="query" size="40">
    When the page is reloaded, a query like this is execued:

    Code:
    SELECT * FROM Music_Groups where description OR band_name LIKE "%$query%"
    Now, that isn't fullproof - you'd have to excape the quotes there, and perhaps mess around with the formatting - perhaps you could provide some radio buttons to allow the user to search for text at the END of the band name/description, or in the front, or anywhere in the middle, as above.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •