I would like to know how to access a variable outside of the following while loop:

```
  $resources = "select * from resources where stage LIKE '%".$stage."%'";

        $run_query = mysqli_query($con, $resources);

        while($row = mysqli_fetch_array($run_query)) {

        $format = $row['format'];
        $title = $row['title'];
        $costs = $row['cost'];
         $stage = $row['stage'];
         $topic = $row['topic'];
         $link = $row['link'];
       }

// Email subject
  $subject = "subject!";
  $subject_us = "New custom resource delivered to: $clean_email";

  $message = '<html><body>';
  $message .= "<p>";
  $message .= "Hi $clean_fullName, <br><br>";
  $message .= " Based on your responses, we have created a custom resource pack tailored to your needs.  <br><br>";
  $message .= "<b>$title</b><br>";
  $message .= "$format <br>";
  $message .= "$costs <br>";
  $message .= "$link <br><br>";

```

[...]
The reason why I do not want to include the mail items in the while loop its because it will send out 10 emails for example for each title, rather than one email with all title, which is why i do not want to include inside the while loop.

Problem is that I cannot access the items inside the while loop and include it below.