liomon41 Posted June 12, 2012 Share Posted June 12, 2012 I'm trying call a jquery function based if a condition in php is true but the problem is the jquery runs whether the condition is true or not... Need help fixing this.... Thanks... <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Show display...</title> <script src="scripts/jquery-1.7.min.js" type="text/javascript"></script> <style type="text/css"> .fadeOutbox{ float:left; padding:8px; margin:16px; border:1px solid red; width:200px; height:50px; background-color:#F00; color:white; } </style> </head> <body> <div class="fadeOutbox"> Click here to fadeOut div </div> <?php ini_set("display_errors","0"); ERROR_REPORTING(E_ALL); include 'config.php'; $query = "select secondteam from fixtures where id = '2' "; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $country = $row['firstteam']; if($country = "Poland"){ // by the way this happens to be false...... ?> <script type="text/javascript"> $(".fadeOutbox").click(function () { $(this).fadeOut('slow'); }); </script> <?php } } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/264061-calling-jquery-function-within-php/ Share on other sites More sharing options...
Mahngiel Posted June 12, 2012 Share Posted June 12, 2012 this isn't a jQuery problem, this is a PHP problem. And the problem lies in where you have: if($country = "Poland"){ // by the way this happens to be false...... The = operand sets the value, to compare you need == or http://php.net/manual/en/language.operators.comparison.php Link to comment https://forums.phpfreaks.com/topic/264061-calling-jquery-function-within-php/#findComment-1353234 Share on other sites More sharing options...
ManiacDan Posted June 12, 2012 Share Posted June 12, 2012 Topic moved to PHP. liomon41, please don't create four copies of a thread. We'll move it to where it belongs. Link to comment https://forums.phpfreaks.com/topic/264061-calling-jquery-function-within-php/#findComment-1353244 Share on other sites More sharing options...
liomon41 Posted June 12, 2012 Author Share Posted June 12, 2012 Yeah my bad.... my bad ... really sorry about that Link to comment https://forums.phpfreaks.com/topic/264061-calling-jquery-function-within-php/#findComment-1353245 Share on other sites More sharing options...
nibbrwebdevelopment Posted June 20, 2012 Share Posted June 20, 2012 if($country = "Poland"){ // by the way this happens to be false...... should be if($country == "Poland"){ // by the way this happens to be false...... Link to comment https://forums.phpfreaks.com/topic/264061-calling-jquery-function-within-php/#findComment-1355574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.