Javascript disable field in php?

i want to disable field when check lab credit hour column in phpmysql if lab credit hour 0 then disable lab field.I am using this code.
[php]

<?PHP $option=""; include_once("connect.php"); $result = mysql_query("SELECT * FROM courses");

while($row = mysql_fetch_array($result))
{
$course2=$row[“Course_Number”];
$course3=$row[“Course_Id”];
$option2.="<OPTION VALUE="$course2">".$course2.’…
}
?>

Course Number:
Select courses <?php echo $option2 ?> [/php]

When you generate the JavaScript function (abc) with PHP, it will always do the same thing - as the output of it never changes once the page has loaded. Therefore - if you want something to happen after the page has loaded - you must write a function in JavaScript that tests the Lab_credit_hr. To get the Lab_credit_hr’s into JavaScript, you could output JavaScript code which can then be used by your function:

You are also echoing out the value of $option2 before the closing tag.

[php] [/php]

Becomes:

[php]<?php

include_once('connect.php');

$courses = mysql_query("SELECT `Lab_credit_hr` FROM `courses`;");

if(mysql_num_rows($courses) >= 1) {
	ob_start();
	
	echo 'var courses = Array();';
	
	while($row = mysql_fetch_array($courses)) {
		echo "courses['", $courses['Course_Number'], "'] = '", $row['Lab_credit_hr']. "';";
	}
	
	$js = ob_get_contents();
	ob_end_clean();
}

?>

[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service