I have a list of 5 items and each has a corresponding button to it which changes its state. When these buttons are clicked for each of them, some database operations are performed and they change from 'Appear' to 'Request' and then last as 'Requested'. Now in the list whenever any item's button turns to 'Requested' state(after clicking from 'Appear' to 'Request'), the next item when clicked from 'Appear', stops at 'Request' and does not changes its state to 'Requested' on clicks. And again the third item's button in the list when clicked changes from 'Appear' to 'Request' and then 'Requested'. May I know what could be the possibility that is showing two different results for the same script. Any advice or help will be appreciated on this, stuck for a long time. Here is the complete code.
<?php
if( ( $rep->checkUserAttemptQuiz( $_SESSION['session_user_id'], $id ) == 2 ) && ( $pass_sql==false ) ){
$module_get=mysql_fetch_array(mysql_query("select * from module_quiz_request_user where request_attempt='3' and user_id='".$_SESSION['session_user_id']."' and module_id='$id'")); ?>
<form action= "moduleList.php" method="POST"> <?php
if( ( $module_get['request_status']=='1' ) && ( $module_get['quiz_status']=='1' ) ) { ?>
<input name="" type="button" value="Requested" class="btn btn-sm btn-success"><?php
}
if($module_get['request_status']=='2') { ?>
<input name="" type="button" onClick="javascript:window.location.href='instructions.php?moduleId=<?php echo $fnc->encode($id) ; ?>';" value="Appear" class="btn btn-sm btn-success"> <?php
}
if( ( $module_get==false ) ) { ?>
<input name="request_3" type="submit" value="Request" class="btn btn-sm btn-info">
<input name="module_id" type="hidden" value="<?php echo $id;?>" class="btn btn-sm btn-success">
</form><?php
}
}
if(isset($_POST['request_3'])) {
$user_id = $_SESSION['session_user_id'];
$module_id = $_POST['module_id'];
$request_status = '1';
$designation_get = mysql_fetch_array(mysql_query("select * from tbl_user where id='$user_id'"));
$designation = $designation_get['designation'];
$salutation = $designation_get['salutation'];
$user_register_date = $designation_get['register_date'];
$corporate_id = $designation_get['created_by'];
$request_updated_day = $designation_get['request_updated_day'];
$level_designation = mysql_fetch_array(mysql_query("select * from tbl_level_email where attemp='3' and designation_id='$designation'"));
$designation_email = $level_designation['designation_email'];
$data = array(
"module_id"=>$module_id,
"user_id"=>$user_id,
"request_status"=>$request_status,
"created_date"=>date('Y-m-d'),
"request_attempt"=>"3",
"user_permission"=>$designation_email,
"quiz_status"=>"1"
);
$db->query_insert( "module_quiz_request_user", $data );
}
?>