PDA

Click to See Complete Forum and Search --> : How to pull album infor and song info out of mysql db?


tony007
Feb 12th, 2006, 06:04 PM
Hi all . i have a mysql database for music information and it has the following fields :


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:
http://i5.photobucket.com/albums/y180/method007/musicdb.jpg

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

?>

neicedover1982
Feb 12th, 2006, 07:38 PM
tony007, yiu can modify the code from the answer and code i gave to your other post http://vbforums.com/showthread.php?t=386882

tony007
Feb 12th, 2006, 07:54 PM
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 :

$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!! :

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

penagate
Feb 13th, 2006, 03:40 AM
$query = 'SELECT `id`, `artist`, `track`, `album`, `title` FROM `wimpy` WHERE `album` = \'moon\'';

To use as a script parameter (assuming you have magic quotes on)
$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
$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.