|
-
Feb 12th, 2006, 07:04 PM
#1
Thread Starter
Frenzied Member
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
?>
-
Feb 12th, 2006, 08:38 PM
#2
Fanatic Member
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
-
Feb 12th, 2006, 08:54 PM
#3
Thread Starter
Frenzied Member
Re: How to pull album infor and song info out of mysql db?
 Originally Posted by neicedover1982
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
-
Feb 13th, 2006, 04:40 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|