SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2002
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Please help me write a PHP search command for this MYSQL table

    Hi I have the following mysql table:

    $result4=mysql_query ("
    CREATE TABLE songs (
    id int(3) unsigned NOT NULL auto_increment,
    song_name TEXT NOT NULL,
    song_id int(3) DEFAULT '0' NOT NULL,
    PRIMARY KEY (id),
    KEY song_name (song_name(50))
    );")or die(mysql_error());


    I'd like to create a search command using this table and PHP, using HTML as interface for webpage.

    The search parameter is by sql parameter song_name above.

    Your help would be much appreciated!

  2. #2
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like
    PHP Code:
    <?php
    $Query
    ="SELECT * FROM songs WHERE song_name LIKE '%{$_GET['search']}%'";
    ?>
    is the typical way one would accomplish such a task. That is of course assuming your search method is get; if it is post, simply change $_GET to $_POST. Will that suffice?

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2002
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Hi Aes thanks a lot for the code, I will give it a try and let you know of the result

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2002
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW how do I present all relevant links that will print out (in HTML) the URL's to those that satisfy the search command?


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
  •