Results 1 to 4 of 4

Thread: How to pull album infor and song info out of mysql db?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow How to pull album infor and song info out of mysql db?

    Hi all . i have a mysql database for music information and it has the following fields :


    Code:
    id ,filename, artist, album, title, remix ,track alternate_name,
    parody ,comments, genre, seconds, filesize, bitrate ,visual, url
    [b]
    I want a query that pulls all albums name for perticuler artist that i ask for. example : singeralbums.php?artist=andy. For each album i want artist name , album name.Furthermore i want a query that pulls all songs for perticuler album and i want these fields for it :id,filename, artist, album,title.Example albumsongs.php?album=star. . I be happy if an expert show me what query produces the result i want.Thanks

    feild data type:


    code for singeralbums.php?artist=andy
    Note : simmiler code for albumsongs.php?album=star but diffrent query.
    <?php

    $user = "root";
    $pw = "";
    $db = "mp3sversion5";

    $mysql_access = mysql_connect("localhost", $user, $pw);
    mysql_select_db($db, $mysql_access);

    $query = "?????????????????";
    $result = mysql_query($query);



    ?>
    ..............
    ..............html
    <?
    while($row = mysql_fetch_assoc($result))
    {

    //echo "<br>Id : {$row['id']} <br>" .
    // "filename :{$row['filename']} <br>" .
    // "artist : {$row['artist']} <br>" .
    // "album : {$row['album']} <br>" .
    // "title : {$row['title']} <br><br>";

    ?>
    .........
    ......... html code for each record in the output set and it is uses above a few of above commented variables

    <?


    } // end of while

    ?>

  2. #2
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: How to pull album infor and song info out of mysql db?

    tony007, yiu can modify the code from the answer and code i gave to your other post http://vbforums.com/showthread.php?t=386882
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to pull album infor and song info out of mysql db?

    Quote Originally Posted by neicedover1982
    tony007, yiu can modify the code from the answer and code i gave to your other post http://vbforums.com/showthread.php?t=386882
    Thanks for u reply. i do not have problem now displaying the records. Now i want to filter my result using this query i get error :

    Code:
    $query  = "SELECT id ,artist,track,album,title FROM wimpy where album="moon";
    instead of

    $query = "SELECT id, artist,track, album,title FROM wimpy";
    i get this following error pointing to sql line!! :

    Code:
    Parse error: syntax error, unexpected T_STRING in
    could u help me with this and also how i can pass the grab passed value and use it in where clause uing php? for example albumsongs.php?album=star and using star value in where clause.Thanks

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How to pull album infor and song info out of mysql db?

    $query = 'SELECT `id`, `artist`, `track`, `album`, `title` FROM `wimpy` WHERE `album` = \'moon\'';

    To use as a script parameter (assuming you have magic quotes on)
    PHP Code:
    $query 'SELECT `id`, `artist`, `track`, `album`, `title` FROM `wimpy` WHERE `album` = \''.$_GET['album'].'\''
    If you do not have magic quotes enabled you will need to escape all quotes in the string
    PHP Code:
    $query 'SELECT `id`, `artist`, `track`, `album`, `title` FROM `wimpy` WHERE `album` = \''.addslashes($_GET['album']).'\''
    otherwise someone will be able to add extra unwanted clauses to your SQL query, thus compromising security.

Posting Permissions

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



Click Here to Expand Forum to Full Width