Title: Getting Post Tile For SQL
Last modified: August 20, 2016

---

# Getting Post Tile For SQL

 *  Resolved [kcb212003](https://wordpress.org/support/users/kcb212003/)
 * (@kcb212003)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/getting-post-tile-for-sql/)
 * I am trying to echo some data from a separate DB I have by using the title of
   the posts and can not figure it out, unless I manually put the post title in 
   the code below. (I mainly need help with the [id=’….’] and if I put <?php the_title();?
   > in the id= I get an error)
 * <?php $t_title = $_GET[‘the_title()’]; ?>
    <?php $con = mysql_connect(“localhost”,”********”,”********”);
   if (!$con) { die(‘Could not connect: ‘ . mysql_error()); } mysql_select_db(“********”,
   $con); $result = mysql_query(“SELECT * FROM products WHERE id=’$t_title'”); echo“
   <table border=’1′> <tr> <th>F</th> <th>L</th> </tr>”; while($row = mysql_fetch_array(
   $result)) { echo “<tr>”; echo “<td>” . $row[‘size’] . “</td>”; echo “<td>” . 
   $row[‘description’] . “</td>”; echo “</tr>”; } echo “</table>”; mysql_close($
   con); ?>

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

 *  Thread Starter [kcb212003](https://wordpress.org/support/users/kcb212003/)
 * (@kcb212003)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/getting-post-tile-for-sql/#post-2958449)
 * or is there an other way to pull data from a different SQL database by using 
   the post tile? something like <?php the_title(); ?> and it looks through the 
   table for that title-id and echos the appropriate column (like description etc..)
 *  Thread Starter [kcb212003](https://wordpress.org/support/users/kcb212003/)
 * (@kcb212003)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/getting-post-tile-for-sql/#post-2958481)
 * SOLVED!!!
 * I should have seen it. Fix code is below if anyone needs it…
 * <?php
    $t_title=get_the_title(); $con = mysql_connect(“localhost”,”********”,”********”);
   if (!$con) { die(‘Could not connect: ‘ . mysql_error()); } mysql_select_db(“********”,
   $con); $result = mysql_query(“SELECT * FROM ******* WHERE *******=’$t_title'”);
   echo “<table border=’1′> <tr> <th>F</th> <th>L</th> </tr>”; while($row = mysql_fetch_array(
   $result)) { echo “<tr>”; echo “<td>” . $row[‘******’] . “</td>”; echo “<td>” .
   $row[‘******’] . “</td>”; echo “</tr>”; } echo “</table>”; mysql_close($con);?
   >

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

The topic ‘Getting Post Tile For SQL’ is closed to new replies.

## Tags

 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [post_title](https://wordpress.org/support/topic-tag/post_title/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [the_title](https://wordpress.org/support/topic-tag/the_title/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [kcb212003](https://wordpress.org/support/users/kcb212003/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/getting-post-tile-for-sql/#post-2958481)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
