Jump to content

Recommended Posts

Hi,

 

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

 

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.  :confused:

Link to comment
https://forums.phpfreaks.com/topic/189739-nesting-javascript-in-php-if/
Share on other sites

you can do it <?php if(1==1){

 

?>

<!-- java script here-->

<?php

}else{

 

}

?>

 

That's basically what he had, except with "$row == 0". Most likely if you're not seeing the JS output you're expecting, there's something wrong with the condition. Could you post more code? At a guess I'd say you're using the mysql_* functions incorrectly.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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