Reputation: 2000
I have a search engine which displays a list of ads, i was wondering how i would capture the username from a result that a user clicks on (using a database query, PDO)
so far i have this but am not sure how to make it relate to the exact result that a user clicks on:
$sql = "SELECT * FROM user WHERE username=:username";
$q = $conn->prepare($sql);
$q->bindParam(':username', $username, PDO::PARAM_STR);
$q->execute();
$row = $q->fetch(PDO::FETCH_ASSOC);
$email1 = $row['email'];
Upvotes: 0
Views: 136
Reputation: 17858
Well in theory your ad has a unique ID doesnt it? As part of your click string such as http://mysite.com/adclick.php?adid=1 it knows to go to the ad ID one url on redirect and you can then increment/store any uses etc.
Upvotes: 1