unknown101 Posted April 8, 2008 Share Posted April 8, 2008 Hi Guys I have the following in my code: (im pretty new this as you will probably tell). $genre_query = mysql_query("SELECT Genre FROM artist_tbl WHERE Artist={$user_search}") or die(mysql_error());; $user_result = mysql_fetch_array( $user_search ); Basically when an artist is entered, I want to check in my "artist_tbl" if that artist is in there and if so print out the genre. Example... Enter Metallica, this is found in my artist_tbl, genre is Metal, which is then returned to the user. I know im missing the last part of the above code, so could anyone give me a hand please? Thanks in advance Quote Link to comment Share on other sites More sharing options...
Cosizzle Posted April 8, 2008 Share Posted April 8, 2008 Give this a go, its almost 3am here so hopefully its right <chuckle> I'll take a look back first thing tomorrow if you cant get it! Best of luck $genre_query = "SELECT Genre FROM artist_tbl WHERE Artist='$user_search'"; $result = mysql_query($genre_query) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
unknown101 Posted April 8, 2008 Author Share Posted April 8, 2008 Thanks for the reply but I managed to get it working with: $result=mysql_query("select Genre from artist_tbl where Artist='$user_search'"); while ($row = mysql_fetch_array($result)) { echo $row['Genre']; } It now prints out the Artist entered and the genre from the db, which brings me to the next stage:| Now I want to be able to say.... if genre = metal, rock, heavyRock, Select 5 random artists with the genre metal, heavyrock from artist_tbl .. but im a little stuck with coding this.. can anyone give a helping hand please? Many thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted April 8, 2008 Share Posted April 8, 2008 There's an entire sticky on order by rand. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.