Jump to content

Calling jquery function within php


liomon41

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

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