title: PHP- getting the value of a cell for use with an api
body: <p>Sorry if this is a stupid question, I'm pretty new at PHP. </p>
  
  <p>So first, here is what I'm trying to do:</p>
  
  <p>I am pulling information from MYSQL and displaying the info on a page. specifically this bit:</p>
  
  <pre><code>while($rowsID = mysql_fetch_assoc($sIDD))
  {
  echo '&lt;tr&gt;';
  foreach($rowsID as $key =&gt; $cell){
      print '&lt;td&gt;'.$cell.'&lt;/td&gt;';
  }
  </code></pre>
  
  <p>This works fine and displays the info I want.</p>
  
  <p>The information from that cell, I want to plug into:</p>
  
  <pre><code>$sid = $rowsID['steamID'];
  $key = '&lt;yoink&gt;';
  $slink =file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' .        $key . '&amp;steamids=' . $sid . '&amp;format=json');
  $myarray = json_decode($slink, true);
  print '&lt;img src=';
  print $myarray['response']['players'][0]['avatarmedium'];
  print '&gt;'; `
  </code></pre>
  
  <p>This does not work. It won't pull the actual number from the cell and put it into $sid. I've at a loss here. I'm googled for days, and most of my code is frankenstiened from bits I've found around here, so I'm not even sure I'm on the right track. I hope I've clearly explained my problem and provided enough info. Thanks for any help.</p>
  
  <p>The full code: </p>
  
  <pre><code>&lt;?php
  $hostname = "";   // eg. mysql.yourdomain.com (unique)
  $username = "";   // the username specified when setting-up the database
  $password = "";   // the password specified when setting-up the database
  $database = "";   // the database name chosen when setting-up the database (unique)
  
  $imgR =  "&lt;td&gt;&lt;img src='/images/red-dot2.png".$cell['red-dot2.png']."'&gt;&lt;/td&gt;";
  $imgG =  "&lt;td&gt;&lt;img src='/images/green-dot2.png".$cell['green-dot2.png']."'&gt;&lt;/td&gt;";
  setlocale(LC_MONETARY, 'en_US');
  // Line 10
  $_GET['id'];
  $name = $_GET['id'];
  
  $link = mysql_connect($hostname,$username,$password);
  mysql_select_db($database) or die("Unable to select database");
  
  $sql = "SELECT Members.PID, Members.ID, Members.Steam_Name, Members.SG_ID\n"
      . "FROM Members WHERE Members.PID = '$name%' ";
  
  //Line 20
  $gas = "SELECT Giveaways.title, Giveaways.cv, Members_1.Page, Giveaways.B, Giveaways.entries\n"
      . "FROM Members_1 INNER JOIN (Members INNER JOIN Giveaways ON Members.SG_ID = Giveaways.giver) ON Members_1.SG_ID = Giveaways.status\n"
      . "WHERE (((Members.PID)='$name'))";
  
  $cvGiven = "SELECT Members.PID, Sum(Giveaways.cv) AS SumOfcv\n"
      . "FROM Members INNER JOIN Giveaways ON Members.SG_ID = Giveaways.giver\n"
      . "GROUP BY Members.PID\n"
      . "HAVING (((Members.PID)=$name)) ";
  
  //Line 30
  $winResults = "SELECT Giveaways.title, Members_1.Page, Giveaways.cv, Giveaways.B, Giveaways.entries\n"
      . "FROM Members INNER JOIN (Members_1 INNER JOIN Giveaways ON Members_1.SG_ID = Giveaways.giver) ON Members.SG_ID = Giveaways.status\n"
      . "WHERE (((Members.PID)=$name)) ";
  
  $cvWon = "SELECT Members.PID, Sum(Giveaways.cv) AS SumOfcvW\n"
      . "FROM Members INNER JOIN Giveaways ON Members.SG_ID = Giveaways.status\n"
      . "GROUP BY Members.PID\n"
      . "HAVING (((Members.PID)=$name)) ";
  
  $sID = "SELECT Members.ID\n"
      . "FROM Members\n"
      . "WHERE (((Members.PID)=$name))";
  
  $get = "SELECT Members.PID, Members.SG_ID\n"
      . "FROM Members";
  
  //Line 40
  
  $result = mysql_query($sql,$link) or die("Unable to select: ".mysql_error());
  $result2 = mysql_query($gas,$link) or die("Unable to select: ".mysql_error());
  $cvTotal = mysql_query($cvGiven,$link) or die("Unable to select: ".mysql_error());
  $cvTotalW = mysql_query($cvWon,$link) or die("Unable to select: ".mysql_error());
  $wins = mysql_query($winResults,$link) or die("Unable to select: ".mysql_error());
  $sIDD = mysql_query($sID,$link) or die("Unable to select: ".mysql_error());
  $getN= mysql_query($get,$link) or die("Unable to select: ".mysql_error());
  
  
  if (!$result) {
      die("Query to show fields from table failed");
  }
  
  if (!$result2) {
      die("Query to show fields from table failed");
  }
  if (!$cvTotal) {
      die("Query to show fields from table failed");
  }
  if (!$sIDD) {
      die("Query to show fields from table failed");
  }
  
  if (!$getN) {
      die("Query to show fields from table failed");
  }
  
  //Line 60
  if (!$cvTotalW) {
      die("Query to show fields from table failed");
  }
  if (!$wins) {
      die("Query to show fields from table failed");
  }
  
  
  ///////////////////////////////////////////////////////////////////////////////////
  //////////////////////////Start Structure//////////////////////////////////////////
  ///////////////////////////////////////////////////////////////////////////////////
  
  
  //Display name
  echo '&lt;h2&gt;[[Breadcrumbs?showHomeCrumb = 0  ]]&lt;/h2&gt;';
  
  //Display Steam ID
  $sid = $rowsID['steamID'];
  $key = '';
  
     $slink = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $key . '&amp;steamids=' . $sid . '&amp;format=json');
     $myarray = json_decode($slink, true);
      print $myarray['response']['players'][0]['avatarmedium'];
     // print '&gt;'; 
  print $sid;
  
  
  echo '&lt;table&gt;';
  
  while($rowsID = mysql_fetch_assoc($sIDD))
  {
  echo '&lt;tr&gt;';
      foreach($rowsID as $key =&gt; $cell){
          print '&lt;th&gt;Steam ID:&lt;/th&gt;'.'&lt;td&gt;'.$cell.'&lt;/td&gt;';
  
      }
  echo'&lt;/tr&gt;';
  }
  echo '&lt;/table&gt;';
  
  //CV totals
  $row = mysql_fetch_assoc($cvTotal);
  $sum = $row['SumOfcv'];
  $rowW = mysql_fetch_assoc($cvTotalW);
  $sumW = $rowW['SumOfcvW'];
  
  //Start CV table
  echo '&lt;div class=cv&gt;';
  echo '&lt;table&gt;';
  echo '&lt;tr&gt;';
  echo '&lt;td&gt;Total CV Given:&lt;/td&gt;';
  echo '&lt;td&gt; $'. number_format ($sum,2). '&lt;/td&gt;';
  echo '&lt;tr&gt;';
  echo "&lt;td&gt;Total CV Won:&lt;/td&gt;";
  echo '&lt;td&gt; $'. number_format ($sumW,2). '&lt;/td&gt;';
  echo '&lt;/tr&gt;';
  echo "&lt;/tr&gt;\n\n";
  echo '&lt;/table&gt;';
  echo '&lt;/div&gt;';
  
  
  
  
  //Start Giveaways List
  echo '&lt;h3&gt;Giveaways&lt;/h3&gt;';
  echo '&lt;div class=llamatable&gt;';
  echo"&lt;table&gt;\n";
  echo'&lt;th&gt;Game&lt;/th&gt;&lt;th&gt;CV&lt;/th&gt;&lt;th&gt;Winner&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;NB?&lt;/th&gt;&lt;th&gt;Entries&lt;/th&gt;';
  
  
  while($row = mysql_fetch_assoc($result2)) {
  
  
  
      print "&lt;tr&gt;\n";
        //Is it a bundle?
        foreach($row as $key =&gt; $cell){
         if ($key == 'B' &amp;&amp; strpos($cell,'1') !== false){
           $cell = str_replace('1',$cell,$imgR);
          } 
          elseif($key == 'B' &amp;&amp; $cell == "0"){
              $cell= $imgG;
         }
        //Set cv format
         if($key == 'cv'){
           $cell= '$'. number_format ($cell,2); //Line 80
          }
          //set breaks if multiple winners
         if (strpos($cell,',') !== false){
           $cell= str_replace(',','&lt;br /&gt;',$cell);
          }
         if($key == 'status' &amp;&amp; strpos($cell, $nameName)){
           $cell = $test;
         }        
          echo"&lt;td&gt;$cell&lt;/td&gt;\n";
  
      }
  
  
      print "&lt;/tr&gt;\n";
  
  
      //print "&lt;/br&gt;\n";
  }// End Giveaways list
  //////////////////////////////////////////////////////////////////////////////////////////
  
  print "&lt;/table&gt;\n";
  print "&lt;/div&gt;";
  
  
  //Start Wins List
  echo '&lt;h3&gt;Wins&lt;/h3&gt;';
  echo '&lt;div class=llamatable&gt;';
  //$fields_num = mysql_num_fields($results);
  echo"&lt;table&gt;\n";
  echo'&lt;th&gt;Game&lt;/th&gt;&lt;th&gt;Contributor&lt;/th&gt;&lt;th&gt;cv&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;NB?&lt;/th&gt;&lt;th&gt;Entries&lt;/th&gt;';
  
  
  while($row = mysql_fetch_assoc($wins)) {
  
      print "&lt;tr&gt;\n";
        //Is it a bundle?
        foreach($row as $key =&gt; $cell){
         if ($key == 'B' &amp;&amp; strpos($cell,'1') !== false){
           $cell = str_replace('1',$cell,$imgR);
          } //Line 110
          elseif($key == 'B' &amp;&amp; $cell == "0"){
              $cell= $imgG;
         }
        //Set cv amount
         if($key == 'cv'){
           $cell= '$'. number_format ($cell,2);
          }
          //set breaks if multiple winners
         if (strpos($cell,',') !== false){
           $cell= str_replace(',','&lt;br /&gt;',$cell);
          }
          echo"&lt;td&gt;$cell&lt;/td&gt;\n";
  
      }
  print "&lt;/tr&gt;\n";
  
  
  
  }// End wins list
  print "&lt;/table&gt;\n";
      echo "&lt;/div&gt;";
  
  
  
  //echo '&lt;/table&gt;';
  //echo '&lt;/div&gt;';
  mysql_close($link);
  ?&gt;
  </code></pre>
  
  <p>I realize the code is probably a disaster, I plan on cleaning it up once I have it working and understand more fully what I'm looking at. I've copie and patched together code from a lot of different sources, as well as attempted my own. Don't hate me. :-)</p>