Title: Using PHP inside PHP
Last modified: August 19, 2016

---

# Using PHP inside PHP

 *  [kilika77](https://wordpress.org/support/users/kilika77/)
 * (@kilika77)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/using-php-inside-php/)
 * Hello,
 * I’m trying to create an e-commerce solution and I am trying to call the title
   of a post inside some other php that calls data from a database. Here is the 
   code now.
 * $query = “SELECT product_name, product_quantity FROM transaction_detail WHERE
   product_name=’**the_title();**‘”;
 * How do I call the title of each post? Thanks very much.
 * Chris
    [Rabbit Pack](http://rabbitpack.com)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Eric Mann](https://wordpress.org/support/users/ericmann/)
 * (@ericmann)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/using-php-inside-php/#post-1169523)
 * Try this:
 * `$query = "SELECT product_name, product_quantity FROM transaction_detail WHERE
   product_name='" . get_the_title() . "';";`
 * I’m using ‘get_the_title()’ here because you’re not echoing the title out to 
   the browser, just storing it in the $query variable. This should work for what
   you need. Let me know if it doesn’t.
 *  [live627](https://wordpress.org/support/users/live627/)
 * (@live627)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/using-php-inside-php/#post-1169587)
 * `$query = "SELECT product_name, product_quantity FROM transaction_detail WHERE
   product_name='the_title();'";` won’t work because only variables, not callbacks,
   can be used inline.
 *  [Eric Mann](https://wordpress.org/support/users/ericmann/)
 * (@ericmann)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/using-php-inside-php/#post-1169591)
 * [@live627](https://wordpress.org/support/users/live627/) – That’s the entire 
   reason I made my suggestion. It uses a simple variable return appended to an 
   existing string to create the query.
 *  Thread Starter [kilika77](https://wordpress.org/support/users/kilika77/)
 * (@kilika77)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/using-php-inside-php/#post-1169626)
 * thanks for the help. sorry i didn’t get back here sooner. for some reason im 
   not getting the rss feeds for any of my topics.
 * i figured it out and just created a variable for a custom field and then sorted
   using that custom field.
 * thanks for the help ericmann and live627

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Using PHP inside PHP’ is closed to new replies.

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 4 replies
 * 3 participants
 * Last reply from: [kilika77](https://wordpress.org/support/users/kilika77/)
 * Last activity: [16 years, 9 months ago](https://wordpress.org/support/topic/using-php-inside-php/#post-1169626)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
