Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6222277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:17:14+00:00 2026-05-24T08:17:14+00:00

Im trying to copy data to clipboard using zclip jquery. problem that im facing

  • 0

Im trying to copy data to clipboard using zclip jquery. problem that im facing is when i copy it will copy everything in the database in field “name”. but what i want is to copy a single name that user clicked. if the click another copy that. not the whole thing. can anyone tell me how to do this. thanks.

this is the zclip code

$(document).ready(function(){
$('p#copy').zclip({
path:'js/ZeroClipboard.swf',
copy:function(){return $('div#copy').text();}
});

MySQL loop:

$query = "SELECT * FROM names ORDER BY id desc";
$result= mysql_query($query) or die ('Mysql Error');
while($row = mysql_fetch_array($result)){
echo  '<div id="copy">'.$row['name'].'</div>';
echo  '<p id="copy">copy</p>';
}

zclip site: http://www.steamdev.com/zclip/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:17:16+00:00Added an answer on May 24, 2026 at 8:17 am

    The HTML you generate is not valid which is hindering you in the end to achieve the result you’re looking for: in HTML an ID can only be used once (see: Element identifiers: the id and class attributes). You are using the same ID for multiple DIVs. That can not work, as an ID must be unique across the whole HTML document.

    Instead assign one ID to each DIV (e.g. by using a counter) and then apply the jquery function on the specific DIV only.

    $idCounter = 0;
    while($row = mysql_fetch_array($result))
    {
        $idCounter++;
        echo  '<div id="copy-div-', $idCounter, '">', $row['name'], '</div>';
        echo  '<p id="copy-p-', $idCounter, '" class="copy-click">copy</p>';
    }
    

    Code-Example: Create multiple IDs with a counter variable

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to copy data from my MYSQL table to SQL Server using
I have a list of files that I'm trying to copy and move (using
I am trying to copy data from an old database into a new one,
I'm trying to get data from multiple XML feeds and copy that data to
I am trying to copy a 5mb database file to data folder from raw
I have a XULRunner application that needs to copy image data to the clipboard.
I'm trying to allocate a block of memory and then copy data into that
I am trying to create a script in Python that will collect data put
Im trying to get a completly data copy from a gridview, itryed clone(), tryed
I am trying to copy a header and a set of data to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.