I really need help.
I am trying to have a setup wherein an admin could enable a client's button that is disabled by default.
So far, I have this code below for the admin. It updates the value column (0 by default) in the button table in the database. And this part is successful.
<input name="enable1" type="submit" id="button" value="Enable Button" />
<?php
if(isset($_POST['enable1'])){
mysql_query("UPDATE button SET value = '1' WHERE cat_no = 'cat1'"); }
?>
And the code for the user is written below. My plan is that, when the admin updates the column value into 1, the code below will echo the enabled button, as by the default, the button is disabled.
And this part is a failure, it does not enable the disabled button. And I noticed, that the first echo in the if statement doesn't work, the only thing that is working is the echo in the else statement where the button is disabled.
<?php
$sql="SELECT value FROM button WHERE cat_no = 'cat1'";
$result=mysql_query($sql) or die(mysql_error());
if ($result == '1'){
echo '<input name="enable2" type="submit" class="inputDisabled"
id="button" value="Proceed to Next Category" />' ;}
else {
echo '<input name="enable2" type="submit" class="inputDisabled"
id="button" disabled="disabled" value="Proceed to Next Category" />';}
?>
I also tried to search for alternatives like jQuery. But I can't make it work. And if possible, when the admin clicks the button, the user's page will refresh automatically.
Please help. I really need guidance. Thank you.