# How to use result of query as a variable?

**URL:** <https://forum.kirupa.com/t/how-to-use-result-of-query-as-a-variable/314599>\
**Category:** programming\
**Created:** [October 3, 2010, 3:17pm UTC](https://forum.kirupa.com/t/how-to-use-result-of-query-as-a-variable/314599 "2010-10-03T15:17:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SokrMan](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@SokrMan](https://forum.kirupa.com/u/SokrMan)\
**Post date:** [October 3, 2010, 3:17pm UTC](https://forum.kirupa.com/t/how-to-use-result-of-query-as-a-variable/314599/1 "2010-10-03T15:17:23Z")

</div>

Hello,  
So I have a content management site set up, but I’m stuck on one part. I have a query

```auto
Select `email` FROM author WHERE author.id IN(SELECT authorid FROM job WHERE id = '$_POST[id]')

```

. I’m a beginner in PHP and SQL. Basically I need the query to run, it will come out with one result and I need that to be where the email is sent to. This is the existing code I have for sending out the email

```php
$subject = " Job Application Confirmation";

$message = "Hello $_POST[name] , \r\rYou, or someone using your email address, has applied for the job: $text Using the Resource Locator at Prahan.com. Keep this as future reference. \r\r Full Name: $_POST[name] \r Location: $_POST[location] \r Email: $_POST[email] \r Additional Information: $_POST[info] \r Job ID: $id \r Job Name: $text \r \r Expect a response shortly. \r\r Regards, Prahan.com Team";

$headers = 'From: Prahan.com Team <noreply@prahan.com>';

    'Reply-To: noreply@prahan.com' . "
" .

    'X-Mailer: PHP/' . phpversion();

$to1 = 'pratik@prahan.com';

mail($to1, $result, $message, $headers);

```

Thanks in Advance!
