Add a class to an element by JQuery, If php condition is checked. Hi. This code does not work. If anybody knows an alternative method I much appreciate it. Thank you.
<form method="post">
<input class="blue" name="btn" type="Submit" value="Submit" />
</form>
<?php
if(isset($_POST["btn"])){
$query = mysqli_query($con,"select * from table");
$row = mysqli_fetch_assoc($query);
$name = $row['name'];
if($name == "kamal"){
?>
<script type="text/javascript">
$('.blue').addClass('green');
</script>
<?php
}
else{
?>
<script type="text/javascript">
$('.blue').addClass('red');
</script>
<?php
}
}
?>