Title: [Plugin: Custom Field Template] php call to database for another variable
Last modified: August 19, 2016

---

# [Plugin: Custom Field Template] php call to database for another variable

 *  [SheldonNesdale](https://wordpress.org/support/users/sheldonnesdale/)
 * (@sheldonnesdale)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-custom-field-template-php-call-to-database-for-another-variable/)
 * I want to use a value stored as a custom field in a mysql query to a table in
   my database to set the value of additional variables?
 * So far I have used the “PHP Code Experimental” field for my query which is:
 *  global $fetched_name
    $sql = “SELECT * FROM sites WHERE url = ‘[cts key=website_url]’“;
   $query = mysql_query($sql, $db); while($result = mysql_fetch_array($query)) {
   $fetched_name = $result[“name”]; }
 * And I’m trying to call the variable in the post with:
    [cts key=0]
 * But perhaps I am missing a step?

The topic ‘[Plugin: Custom Field Template] php call to database for another variable’
is closed to new replies.

 * ![](https://ps.w.org/custom-field-template/assets/icon-256x256.png?rev=1966286)
 * [Custom Field Template](https://wordpress.org/plugins/custom-field-template/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-field-template/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-field-template/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-field-template/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-field-template/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-field-template/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [SheldonNesdale](https://wordpress.org/support/users/sheldonnesdale/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-custom-field-template-php-call-to-database-for-another-variable/)
 * Status: not resolved