<?php
    define('IN_BANDTOPIA', "You're here!!!");
    ini_set("display_errors","1");
    error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);	
	include_once('include/pageStart.php');
	
    $userID=$_SESSION['UserId'];
    // Get ArtistId
    $query = "SELECT ArtistId FROM ArtistUsers WHERE UserId = $userID";
    $result = mysql_query($query, $mydb) or die(mysql_error() . "<br>" . $query);
    $row = mysql_fetch_array($result);
    $artistID =$row['ArtistId'];

    // Get Artist name
    $query = "SELECT Name FROM Artists WHERE ArtistId = $artistID";
    $result = mysql_query($query, $mydb) or die(mysql_error() . "<br>" . $query);
    $row = mysql_fetch_array($result);  

    // Greet Artist
    print("<h1>Welcome ".$row['Name']."</h1>");

    print("<h1>Fans:</h1>");
    $query = "SELECT UserId FROM FavArtists WHERE ArtistId = $artistID AND StreetTeam = 0";
    $result = mysql_query($query, $mydb) or die(mysql_error() . "<br>" . $query);
        echo("<div style=\"height:120px;width:250px;overflow-y:scroll;\">");
        while($row = mysql_fetch_array($result))
        {
          $query = "SELECT * FROM Users WHERE UserId = {$row[0]}";
          $res = mysql_query($query, $mydb) or die(mysql_error() . "<br>" . $query);
          $r = mysql_fetch_array($res);
          $fanFirstName = $r[4];
          $fanLastName = $r[5];
          echo($fanFirstName." ".$fanLastName."<br>");
        }
        echo("</div>");	
	
  // Display Artist's Bio
    print("<h1>Bio: </h1>"); 
    $query = "SELECT Bio FROM Artists WHERE ArtistID = $artistID";
    $result = mysql_query($query, $mydb) or die(mysql_error() . "<br>" . $query);
    $row = mysql_fetch_array($result);
    $bio = $row[0];
    echo("<div style=\"height:120px;width:250px;\">");	
    print("    ".$bio);	
	echo("</div>");
	

  //upcoming events
  // Upcoming Events
  print("<h1>Events: </h1>");
  print("<form method=\"post\" action=\"artist_profile.php\">");	
  print("<p>Event Name: <input type=\"text\" size=\"25\" name=\"eventName\" /></p>");
  print("<p>Month: <select name=\"month\"> ");
  print("<option>1</option>");
  print("<option>2</option>");
  print("<option>3</option>");
  print("<option>4</option>");
  print("<option>5</option>");
  print("<option>6</option>");
  print("<option>7</option>");
  print("<option>8</option>");
  print("<option>9</option>");
  print("<option>10</option>");
  print("<option>11</option>");
  print("<option>12</option>");
  print("</select>");
  print("<p>Day: <select name=\"day\"> ");
  print("<option>1</option>");
  print("<option>2</option>");
  print("<option>3</option>");
  print("<option>4</option>");
  print("<option>5</option>");
  print("<option>6</option>");
  print("<option>7</option>");
  print("<option>8</option>");
  print("<option>9</option>");
  print("<option>10</option>");
  print("<option>11</option>");
  print("<option>12</option>");
  print("<option>13</option>");
  print("<option>14</option>");
  print("<option>15</option>");
  print("<option>16</option>");
  print("<option>17</option>");
  print("<option>18</option>");
  print("<option>19</option>");
  print("<option>20</option>");
  print("<option>21</option>");
  print("<option>22</option>");
  print("<option>23</option>");
  print("<option>24</option>");
  print("<option>25</option>");
  print("<option>26</option>");
  print("<option>27</option>");
  print("<option>28</option>");
  print("<option>29</option>");
  print("<option>30</option>");
  print("<option>31</option>");
  print("</select>");

  print("<p>Year: <select name=\"year\"> ");
  print("<option>".date("Y")."</option>");
  print("<option>".(date("Y")+1)."</option>");
  print("</select>");

  print("<p>Location: <input type=\"text\" size=\"50\" name=\"location\" />");
  print("<p>Description:<br> <textarea name=\"description\" rows=\"4\" columns=\"36\">What's the event about?</textarea></p>");
  print("<p>Price: <input type=\"text\" size=\"10\" name=\"price\" /></p>");
  print("</form>");

    mysqli_close($mydb);

echo '<form method="post" action="/promotion/index.php?action=sendmessage>
<input type="submit" value="Send Message to Fans" />
</form>	';		
?>	

