Jump to content

[SOLVED] quick question


paulman888888

Recommended Posts

Wrong forum mate, but I will give you a short answer nonetheless :) Using CSS, this will only work in browsers supporting the :hover pseudo-class on most elements (and not only on the anchor element as many browsers do):

 

.tabletype1 {
background-color: #00FF00;
}

.tabletype1:hover {
/* red background when mouse 'hovers' above the element */
background-color: red;
}

 

The other solution would be changing the style with javascript's "onmouseover" trigger.

Link to comment
Share on other sites

i have had ago but i get no luck.

I think its because i use mysql as well.

anyway heres my code

<?php
$result = mysql_query("SELECT * FROM downloads ORDER BY id ASC"); 
$i = 0; // setup a counter
echo '<table border="1" width="550">';
echo "<tr><th>ID</th><th>Name</th><th>Download Location</th><th>Size</th><th>Download</th></tr>";
while($row = mysql_fetch_array( $result ))
{
    // alternate class
    $class = ($i%2 == 0) ? '#00FF00' : '#FF0000';
$class2 = ($i%2 == 0) ? '#FFFF00' : '#316AC5';

// Print out the contents of each row into a table
echo '<tr onmouseover="this.style.backgroundColor = "'$class'";" onmouseout="this.style.backgroundColor = "'$class2'";">';
echo "<td><a href='info.php?id=".$row['id']."'>".$row['id']."</a></td>\n";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['location']."</td>";
echo "<td>".$row['Size']."</td>";
echo '<td><center><a href="'.$row['location'].'"><img src="Images/downloadsm.png" /></a></center></td>';
echo "</tr>";
    $i++; // increment counter
}

echo "</table>";

?>

 

And i keep getting errors.

 

Thankyou everyone

Link to comment
Share on other sites

You're messing up the single and double quotes. Let me fix it kindly :)

 

<?php
$result = mysql_query("SELECT * FROM downloads ORDER BY id ASC"); 
$i = 0; // setup a counter
echo '<table border="1" width="550">';
echo "<tr><th>ID</th><th>Name</th><th>Download Location</th><th>Size</th><th>Download</th></tr>";
while($row = mysql_fetch_array( $result ))
{
    // alternate class
    $class = ($i%2 == 0) ? '#00FF00' : '#FF0000';
$class2 = ($i%2 == 0) ? '#FFFF00' : '#316AC5';

// Print out the contents of each row into a table
echo "<tr onmouseover=\"this.style.backgroundColor = '".$class."';\" onmouseout=\"this.style.backgroundColor = '".$class2."';\">";
echo '<td><a href=\"info.php?id='.$row['id'].'">'.$row['id']."</a></td>\n";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['location']."</td>";
echo "<td>".$row['Size']."</td>";
echo '<td><center><a href="'.$row['location'].'"><img src="Images/downloadsm.png" /></a></center></td>';
echo "</tr>";
    $i++; // increment counter
}

echo "</table>";

?>

 

Just to make it clear, $class is the color the row gets when moused over, and $class2 is the color the row gets when the mouse clears the row again. If you want the color to return to the background color of the element beneath it, use "transparent" as the color for $class2.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.