title: Running 2 Mysql queries via PHP
body: <p>I am trying to run the below query, I've figured out the SET statements are a separate query to the  SELECT query. I've found a few answers relating to this but cant get them to work in my code.</p>
  
  <p>It all works fine in phpMyAdmin but not in this PHP webpagepage</p>
  
  <p>How do i go about running the 2 queries to get the result? </p>
  
  <pre><code>  $queryRank = "SET @rnk=0; SET @rank=0; SET @curscore=0;
  
  SELECT rank FROM
          (
           SELECT AA.*,BB.playerId,
          (@rnk:=@rnk+1) rnk,
          (@rank:=IF(@curscore=best3,@rank,@rnk)) rank,
          (@curscore:=best3) newscore
          FROM
            (
             SELECT * FROM
             (SELECT COUNT(1) scorecount,best3
             FROM leaderboard GROUP BY best3
          ) AAA
      ORDER BY best3 DESC
      ) AA LEFT JOIN leaderboard BB USING (best3)) A
      WHERE playerId='$memberID'";
  
  
  
  $resultRank = mysqli_query($link, $queryRank);
  
  if (mysqli_num_rows($resultRank) &gt; 0) {
  
          $rowRank = mysqli_fetch_array($resultRank);
  
  echo "&lt;p class='mt-2 statNumber'&gt;".$rowRank['rank']."&lt;/p&gt;";
  
  
      } else {
  
          echo "No events played";
  
  
     }
  </code></pre>