quantumdecipher Posted April 9, 2011 Share Posted April 9, 2011 Basically I have a page which returns data from a SQL database. Column results have a mouseover javascript which pops up a message when hovered. I highlighted the code which gives me problem. What i want to do here is that when a the sql query for the field errorMessage has no value, it returns a popup (which functions properly so far), but returns the content of the field errorMessage if it has value in the database. Here's my code : <?php $conn = mysql_connect("localhost", "root", "123456") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $sql = mysql_query("SELECT * FROM buccaneer ORDER BY portNumber ASC") or die(mysql_error()); if(mysql_num_rows($sql) == 0) { echo "<center><b>No ORDER/S in Queue</b></center>"; } else { while($result = mysql_fetch_array($sql)) { echo"<tr><td class='tableContent'>".$result['portNumber']."</td>"; echo"<td class='tableContentDate'>".$result['dueDate']."</td>"; echo"<td class='tableContent'><span onmouseover=\"tooltip.show('Click to search ".$result['workObject']." at Shop Floor');\" onmouseout=\"tooltip.hide();\"><a href='http://*******?object=".$result['workObject']."&search=Overview'>".$result['workObject']."</a></span></td>"; echo"<td class='tableContent'><span onmouseover=\"tooltip.show('Click to search ".$result['salesOrder']." at Shop Floor');\" onmouseout=\"tooltip.hide();\"><a href='http://*******?object=".$result['salesOrder']."&search=Overview'>".$result['salesOrder']."</a></span></td>"; echo"<td class='tableContent'>".$result['systemStatus']."</td>"; if ($result['errorMessage'] = "") { echo"<td class='tableContent'><span onmouseover=\"tooltip.show('Click to add Error Message to ".$result['workObject']."');\" onmouseout=\"tooltip.hide();\"><a href='addRemarks.php'>".$result['systemRemarks']."</a></span></td>"; } else { echo"<td class='tableContent'><span onmouseover=\"tooltip.show('".$result['errorMessage']."');\" onmouseout=\"tooltip.hide();\">".$result['systemRemarks']."</a></span></td>"; } echo"<td class='tableContent'>".$result['orderType']."</td>"; echo"<td class='tableContent' id='customerName' name='customerName'>".$result['customerName']."</td>"; echo"</tr>"; }} ?> Please help as this is my project. I'm still a newbie in PHP and I have been coding for a few months only. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/233192-need-help-on-returning-a-custom-message-when-mouse-over/ Share on other sites More sharing options...
joel24 Posted April 9, 2011 Share Posted April 9, 2011 you need to use ==, rather than the assigning = in this line if ($result['errorMessage'] = "") { Quote Link to comment https://forums.phpfreaks.com/topic/233192-need-help-on-returning-a-custom-message-when-mouse-over/#findComment-1199216 Share on other sites More sharing options...
quantumdecipher Posted April 9, 2011 Author Share Posted April 9, 2011 Thanks! It worked! Quote Link to comment https://forums.phpfreaks.com/topic/233192-need-help-on-returning-a-custom-message-when-mouse-over/#findComment-1199222 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.