Thank you for the helps. I am middle of a proble and I am n't able to solve this simple problem. Please help me.
my code is :-
<?php
$sel="select * from demo1 where paper_type='Quantitative'";
$exe=mysql_query($sel);
while($rt=mysql_fetch_array($exe))
{
$array_val[]=$rt['condition'];
}
?>
<script>
var val1 = "<?php echo($array_val[0]); ?>";
var val2 = "<?php echo($array_val[1]); ?>";
var val3 = "<?php echo($array_val[2]); ?>";
var val4 = "<?php echo($array_val[3]); ?>";
var val5 = "<?php echo($array_val[5]); ?>";
if(val1 == "a" )
{
document.getElementById("imgClick1").src = "images/a.jpg";
document.getElementById('num1').style.color = "#000";
}
else if(val1 == "b")
{ document.getElementById("imgClick1").src = "images/b.jpg";
document.getElementById('num1').style.color = "#fff";
}
if(val2 == "a" )
{
document.getElementById("imgClick2").src = "images/a.jpg";
document.getElementById('num2').style.color = "#000";
}
else if(val2 == "b")
{
document.getElementById("imgClick2").src = "images/b.jpg";
document.getElementById('num2').style.color = "#fff";
}
if(val3 == "a" )
{
document.getElementById("imgClick3").src = "images/a.jpg";
document.getElementById('num3').style.color = "#000";
}
else if(val3 == "b")
{
document.getElementById("imgClick3").src = "images/b.jpg";
document.getElementById('num3').style.color = "#fff";
}
</script>
Using php I get the value from MySQL to php array '$array_val[]' and place the value into javascript variable but when I am trying to check it by using if condition, it just working on the first if condition.
please help me, how I can use the other if condition also?