Boxerman Posted December 12, 2008 Share Posted December 12, 2008 Hi guys.. ive got a music site and would like to add 3 different things like this... so the first one would be featuredartist 2nd most requested song.. and 3rd number 1 song that week.. ok.. i will have 3 different databases... and 1 called featuredartist 2nd mostrequested 3rd topsong so i will enter the data into each database.. such as image link and text.. my problem is.. how do i grab it from the database? thanks Quote Link to comment Share on other sites More sharing options...
justinh Posted December 12, 2008 Share Posted December 12, 2008 Hmm.. this would take some serious writing to explain and show you how it would be done.. I suggest you read a tutorial on mysql/php http://www.tizag.com/mysqlTutorial/ Quote Link to comment Share on other sites More sharing options...
Boxerman Posted December 12, 2008 Author Share Posted December 12, 2008 i understand basics.. its 2 facts.. how i connect to database to grab the information.. and what code to display it? $row['image'] that? Quote Link to comment Share on other sites More sharing options...
justinh Posted December 12, 2008 Share Posted December 12, 2008 <?php //Puts all the required MYSQL database info into variables $host = "host here"; $username = "username here"; $password = "password here"; $dbname ="database name here"; //connects to the MYSQL database with the information provided above mysql_connect($host,$username,$password) or die(mysql_error()); //Selects the database name mysql_select_db($dbname); $getfeaturedartist = mysql_query("SELECT * FROM featuredartist"); while($artist = mysql_fetch_array($getfeaturedartist)){ $featured = $artist['featuredartist']; //this grabs whatever is in the field featuredartist, and puts it into a variable } echo "Today's featured artist is:".$featured."<br />"; ?> think your looking for something like that. please note this code has not been tested. Quote Link to comment Share on other sites More sharing options...
justinh Posted December 12, 2008 Share Posted December 12, 2008 also, I'm not sure its necessary to have 3 databases. I'm pretty sure what you need could easily be done with 1 database, and 3 tables. Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2008 Share Posted December 12, 2008 I was just about to post that. I think he is talking about tables not a database. Quote Link to comment Share on other sites More sharing options...
Boxerman Posted December 12, 2008 Author Share Posted December 12, 2008 to grab a field? 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.