Jump to content

Button to Copy (or highlight) a cell


MesaFloyd

Recommended Posts

Rookie here(old guy), but some <dangerous> knowledge.

I make a table that has rows called from a DB (works fine)

I need to add a column with button for each row, that when pressed, will copy to clipboard the content of a particular cell in that row ...'pcidip'...  If too complex to copy to clipboard, alternatively, perhaps just higlight the content of the cell and the user can then <cntl>C to copy to clipboard.

 

I need it to operate across all platforms (IE, Chrome, Firefox... etc)

Can this be <simply> done in PHP?

Here is what I have

... snip...

echo "<table border='1'>";
echo "<tr> <th>Username</th> <th>Password</th> <th>IP Address</th> <th>Email Address</th> <th>Chk</th> <th> Last Visit Date-Time </th> <th>Copy/Highlight IP</th> </tr>";

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result ))
{
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['username'];
echo "</td><td>";
echo $row['password'];  //show the passwords
//echo " Blocked ";     //passwords are blocked - use this -or- the above, not both 
echo "</td><td>"; 
echo $row['pcidip'];
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['emailchk'];
echo "</td><td>"; 

if ($row['datetime'] < date("Y.m.d - H:i:s",time()-60*60))
	{
	echo "<font color='red'>";
	echo $row['datetime'];
	echo " (zzzz)";
	}
else
	{
	echo "<font color='green'>";
	echo $row['datetime'];
	}

echo "</td><td>";	
echo "button here";  //want button to copy 'pcidip' to clipboard <or HL> - don't know how yet
echo "</td></tr>"; 
}

Im sure this would be simple but the only thing I can find is with JS and unique to IE.

Please be gentle with me... Im not that savvy, but I try hard...

Thanks in Advance

Floyd

 

Link to comment
https://forums.phpfreaks.com/topic/198107-button-to-copy-or-highlight-a-cell/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.