Page 1 of 1
Help with code that outputs rows from DB
Posted: Thu Aug 24, 2006 11:34 pm
by nickman013
Hello,
I am outputting rows from a DB, but I am having trouble becasue I need the rows to change color when they are highlighted, but I am having a major apostrophe problem.
My code now.
Code: Select all
echo "<tr style="background-color:#CCCCCC;"
onMouseOver="this.className='highlight'">";
echo "<td align=left width=100 valign=top><font size=2>".$row4['name']."</font></td>";
echo "<td align=left><font size=2>".$row4['comment']."</font></td>";
echo '<td><font size=2><a href=/deletecomment.php?id='.$row4['id'].'>Delete Comment</a></td></tr>';
Can anybody make the first echo work for me, ive been tryign for like a hour.
Thanks so much!!!
Re: Help with code that outputs rows from DB
Posted: Thu Aug 24, 2006 11:41 pm
by Luke
nickman013 wrote:Code: Select all
echo "<tr style="background-color:#CCCCCC;" onMouseOver="this.className='highlight'">";
echo "<td align=left width=100 valign=top><font size=2>".$row4['name']."</font></td>";
echo "<td align=left><font size=2>".$row4['comment']."</font></td>";
echo '<td><font size=2><a href=/deletecomment.php?id='.$row4['id'].'>Delete Comment</a></td></tr>';
Try that
Posted: Thu Aug 24, 2006 11:49 pm
by nickman013
Thanks that worked!!
But now I have a client side question, but I dont wanna open a new thread for this question.
The question is, do you know why the background color doesnt change when the mouse is on it.
The code is this.
Code: Select all
echo "<tr style=\"background-color:#CCCCCC;\" onMouseOver=\"background-color:#8888FF;\">";
Posted: Thu Aug 24, 2006 11:51 pm
by Luke
Because that's not the way you do it...
Look here:
http://www.w3schools.com/dhtml/dhtml_css.asp
Posted: Thu Aug 24, 2006 11:55 pm
by Luke
or you could do something like this (stolen from phpmyadmin)
Code: Select all
table tr.odd:hover{
background-color: #CCFFCC;
}
Posted: Fri Aug 25, 2006 12:05 am
by nickman013
I did the one above, but it doesnt seem to work.
My code now.
Code: Select all
<style type=text/css>
table tr.odd:hover{
background-color:#CCFFCC;
}
</style>
<table border=0>
<tr><td><b>NAME</b></td><td><b>COMMENT</b></td></tr>
<?
$username2= "muot_report";
$password2= "password";
$database2= "muot_report";
$connection2 = mysql_connect('localhost',$username2,$password2);
mysql_select_db($database2);
$sql4 = "SELECT * FROM `comments` WHERE who =" . $_GET['id'] . "";
$result4 = mysql_query($sql4) or die(mysql_error());
while($row4 = mysql_fetch_array($result4)) {
echo "<tr>";
echo "<td align=left width=100 valign=top><font size=2>".$row4['name']."</font></td>";
echo "<td align=left><font size=2>".$row4['comment']."</font></td>";
echo '<td><font size=2><a href=/deletecomment.php?cmtid='.$row4['id'].'&muotid='.$_GET['id'].'>Delete Comment</a></td></tr>';
} mysql_close($connection2);
?>
</table>
THANKS SO MUCH!
Posted: Fri Aug 25, 2006 12:07 am
by nickman013
I got it. I re-read the CSS and didnt relize I had to label the rows.
Thanks so Much!!
Posted: Fri Aug 25, 2006 12:11 am
by Luke