I'm trying to inject the_permalink into the url of this query.
$result = mysql_query("SELECT link_title, link_destination, link_unique_clicks
FROM wp_tracking_clicks, wp_tracking_links
WHERE wp_tracking_clicks.link_id = wp_tracking_links.link_id
AND wp_tracking_clicks.click_refer = 'http://www.url.com'");
while ($row = mysql_fetch_assoc($result)) {
echo $row['link_title'];
echo $row['link_destination'];
echo $row['link_unique_clicks'];
}
The code above works but I need to display this in a template, so I need to get the pages current url.
All attempts to put the_permalink directly, or into a variable and then pass it to the query fail. I've tried both
AND wp_tracking_clicks.click_refer = 'the_permalink'");
and
$link=the_permalink();
AND wp_tracking_clicks.click_refer = '$link'");
I'm sure I'm missing something simple but any help would be greatly appreciated.