raman Posted November 2, 2008 Share Posted November 2, 2008 I don't know why I don't get the effect of color change in table rows though I have put everything correctly in my code.I have used the javascript function bgr_color and then used onMouseOver and onMouseOut attributes for <tr> tag but don't get the effect.My code is as under <?php $org=$_POST['Organism']; $cat=$_POST['Category']; $con= mysql_connect("localhost.localdomain","root","***"); if(!$con) { die('Could not connect:'.mysql_error()); } else { echo"<head><script type='text/javascript' src='selctall.jsp'> </script> <script type='text/javascript'> function bgr_color(obj,color) { obj.style.backgroundColor=color } </script> </head>"; echo "<h2><div align='center'><font color='green'>Results of your query</font></div></h2><body bgcolor='wheat'>"; } mysql_select_db("Protvirdb",$con); echo "<table border='1'><form id='field' action='down2.php' method='post'> <tr><th><input type='checkbox' name='checkall' onclick='return selectAll(field);'></th><th>Organism</th> <th>Category</th> <th>Protein</th> <th>Brief Description</th> </tr>"; $arry=array(); foreach($_POST['Organism'] as $org){ foreach($_POST['Category'] as $cat){ $ret=mysql_query("SELECT * FROM cryptovir WHERE Organism='$org' AND Category='$cat'"); $count=mysql_num_rows($ret); $counter+=$count; if ($count==0){ array_push($arry,$cat); } } echo "<div>No records found for categories: "; for ($i=0;$i<count($arry);$i++){ echo"$arry[$i] "; } echo "for <i>$org</i></div>"; } echo"<p>The total number of records retrieved by your query is $counter.</p><input type='submit' name='excel' value='Download selected items as excel file.'><input type='submit' name='fasta' value='Download as fasta file'>"; foreach($_POST['Organism'] as $org){ foreach($_POST['Category'] as $cat){ $ret=mysql_query("SELECT * FROM cryptovir WHERE Organism='$org' AND Category='$cat'"); $count=mysql_num_rows($ret); if($count==0){ }else { //echo"<p> The number of records retrieved by your query is $count</p>"; while($row=mysql_fetch_array($ret)) { $ort=$row['Organism']; $tre=$row['Category']; $key=$row['SNo']; // echo"<form action='down.php' method='post'>"; echo "<tr bgcolor='#FFFFFF' onMouseOver='bgr_color(this,'#FF0000')' onMouseOut='bgr_color(this,'#FFFFFF')'>";echo"<td><input type='checkbox' name='pro[]' value=\"$key\"></td>"; echo"<td><i>".$row['Organism']."</i></td>"; echo"<td>".$row['Category']."</td>"; echo"<td><a href=\"seq2.php?sn=$key\">".$row['Name']."</a></td>"; echo"<td>".$row['Brief_Description']."</td>"; echo "</tr>"; } } } } echo"</form></table><br>"; mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
ratcateme Posted November 2, 2008 Share Posted November 2, 2008 try replacing the '#FF0000' with \'#FF0000\' Scott. Quote Link to comment Share on other sites More sharing options...
raman Posted November 2, 2008 Author Share Posted November 2, 2008 No it did not work. Please suggest something else. Quote Link to comment Share on other sites More sharing options...
dezkit Posted November 2, 2008 Share Posted November 2, 2008 Block out your mysql password... Quote Link to comment Share on other sites More sharing options...
raman Posted November 2, 2008 Author Share Posted November 2, 2008 How do I block out mysql password and what has it got to do with javascript effect ? Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted November 2, 2008 Share Posted November 2, 2008 You can't edit your first post anymore only a forum administrator can. It does not have to do anything with your problem but it could create one if someone decided to hack your server. also your problem is not really php related. I suggest you look in your browser source to see what goes wrong and check for javascript errors Quote Link to comment Share on other sites More sharing options...
Flames Posted November 2, 2008 Share Posted November 2, 2008 @ raman - code tags Quote Link to comment Share on other sites More sharing options...
raman Posted November 2, 2008 Author Share Posted November 2, 2008 I have still not got the answer to my problem.I have checked the error console of the browser. It shows error as: Error: syntax error Source File: http://localhost/blalnl/que6.php Line: 1, Column: 15 Source Code: bgr_color(this, Can someone solve now ? Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted November 2, 2008 Share Posted November 2, 2008 it's because you're not using your quotes right change <?php echo "<tr bgcolor='#FFFFFF' onMouseOver='bgr_color(this,'#FF0000')' onMouseOut='bgr_color(this,'#FFFFFF')'>"; ?> to <?php echo "<tr bgcolor='#FFFFFF' onMouseOver=\"bgr_color(this,'#FF0000')\" onMouseOut=\"bgr_color(this,'#FFFFFF')\">"; ?> Quote Link to comment Share on other sites More sharing options...
raman Posted November 2, 2008 Author Share Posted November 2, 2008 Thanks a lot.The problem got sorted out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.