0

I am returning values from a database search that are currently hyperlinked to redirect to search.php. I would like to change my code so that instead of redirecting to search.php, the text of the link will be copied to clipboard when the user clicks it with the mouse and the user will remain on the same page. An easy solution would be greatly appreciated. Here is the code I am currently using.

while($row = mysql_fetch_assoc($find_parts))
{
$name = $row['name'];

$id = $row['id'];

echo "<a href='search.php?id=$id'>$name</a><br />";
}

Basically all I want is for name to be copied to clipboard when the link is clicked

cchapman
  • 2,668
  • 6
  • 42
  • 59
  • 1
    The would be client side interaction so not PHP. I'd start here, http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript. – chris85 Feb 05 '16 at 19:05
  • php has no clipboard, and cannot do ANYTHING about client-side clipboards. you'd need javascsript for this, which means the php stuff is basically irrelevant. what you do on the server is never seen by the client. – Marc B Feb 05 '16 at 19:06

1 Answers1

0

I'd add this as a comment but unfortunately I don't have quite enough rep to do so yet. I'd recommend zeroclipboard. It uses a mix of flash and javascript and should be able to do what you need.

sm1215
  • 428
  • 2
  • 13