SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Searching through databases

    To all PHP & MySQL programmers,

    I have a problem at hand. I run a website that has a music archive in it. What I need to do is to remove certain songs from a specific music publisher. The information is currently stored in a column entitled 'content' (which includes the music as well). Right now I have letters that visitors can click on (for example A, B, C, etc.) and will display all the songs in that letter category. How can I get it to display all the songs excluding those from that particular music publisher? I know I need some sort of search query thing, but that's about all I know. Any help would be much appreciated! TIA!

    Regards,

    Leo Chan

  2. #2
    grasshoppa Snowbird122's Avatar
    Join Date
    Apr 2001
    Location
    Austin
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It depends on how you are extracting the data from the database. Most likely, you are using a SQL query. It probably looks something like:

    Select * from songs

    where songs is the name of the table that the songs are in. If you add a "where" clause to this query, it will filter out unwanted songs. For example:

    Select * from songs where content <> 'bad publisher'
    http://www.echo-consulting.net - Sound Solutions for Online Inspriations.

  3. #3
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea, if you have a table like this

    table songs
    ----------------------------------
    | ID | title_song | publisher_id |
    ----------------------------------

    the you justy simply have to do this query

    SELECT title_song FROM songs WHERE published_id != bad_publisher_id;

    Could you provide us your table definition?

  4. #4
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i actually didn't split up the table columns that way (maybe i should have).

    as of now, the fields are:

    ID, title, author, content, dateadded, letter

    the majority of the information is stored in the content column.. the publisher is listed in the content column with some other information as well, so i think there has to be some sort of filtering system for that?

    any help would be appreciated! thanks!

    regards,

    leo chan

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i wouldn't know how to code this, but i can sorta tell you a way.
    >run a query to get the stuff in the content column.
    >use a string function to search for the pulishers info in the query results
    >delete that row if it contains it, otherwise keep looking.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    grasshoppa Snowbird122's Avatar
    Join Date
    Apr 2001
    Location
    Austin
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, you can use SQL to get exactly what you want.

    Select * from songs where content NOT LIKE '%bad publisher%'

    The % is a wildcard command that will filter the string for you.
    http://www.echo-consulting.net - Sound Solutions for Online Inspriations.


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
  •