For the sake of ease, I simplified the script below.
TABLE: users
id | username | location
12 | best_chef | SF, CA
15 | muffin_girl | Miami, FL
TABLE: list
post_id | userid | post
95 | 15 | check out my new recipe!
96 | 12 | I love <a href="profile.php?id=$12">best_chef</a> 's recipes
Here's the SQL query i'm using to display posts:
$table = query("SELECT id, post, post_id, username FROM list, users WHERE list.userid = users.id");
HTML:
<div class="update">
<div class="user"><?php echo $usermame ?></div> //"muffin_girl"
<div class="post"><?php echo $post ?></div> // "i love best_chef's recipes"
</div>
What I am trying to do is to add a popup box that will display the location of the person tagged in a post WHEN the anchor of the post is hovered. Something like that:
<div class="popup"><?php echo location ?></div
Question:
How can I join the anchor tag of the posts with the location of the users? Plus, not all posts contain an anchor tag.
Would this be feasible? i have a feeling i'm overthinking this.
EDIT
Desired output/pseudocode:
$sql = "SELECT post, username, location FROM list, users WHERE post like '%{TODO:anchor text}%' = users.username LIMIT 1";