Page 1 of 1

Nesting javascript in PHP If ?

Posted: Mon Jan 25, 2010 10:08 am
by toasty525
Hi,

is it posible to nest simple java script in a PHP IF statment for example i have the following code:

Code: Select all

 
if ($row == 0)
    {
        ?>
        <SCRIPT language="JavaScript">
        
        alert('Sorry not this time, Please try again !');
        
        </SCRIPT>
        <? 
    }
else
    {
        echo $row['prize'];
    }
 
When $row = 0 its meant to show an alert box but it dosnt work. :?:

Re: Nesting javascript in PHP If ?

Posted: Mon Jan 25, 2010 10:29 am
by AbraCadaver
Works great if $row equals 0, so if it doesn't display the javascript then $row does not equal 0.

Code: Select all

echo $row;