mmarif4u Posted March 21, 2007 Share Posted March 21, 2007 Hi guys i have a liitle problem in ifelse... i have a page where there are 4 buttons, i provide pakages for users. if the package no is 6 the three button will not work. but for the package 1 all the buttons will work... But i facing problems with this... in the following code i use package 6 then 1 package user access only level(means that if he click on the buttons by number he get same result.) This is the codition Code where package is selected : $query = "SELECT nrpackage FROM m_package where nrpackage='$session_nrpackage'"; $result = mysql_query($query) or die(mysql_error()); if ($session_nrpackage == '6') { $num = 5; } else{ $num =1; //$num = 3; $num = 4 ; } This the js code for page selection: <script language="JavaScript"> function redirect_selection(action){ var sel_action = ""; var location; var cdlevel_enc = document.selection.cdlevel_enc.value ; var cdsubject_enc = document.selection.cdsubject_enc.value ; var tyexercise_enc = document.selection.tyexercise_enc.value ; //1-set,2-topic,3-difficulty,4-randomise if(action == 1){ sel_action = "std_rev_set_sel.php"; }else if( action==2 ){ sel_action = "std_rev_topic_sel.php"; }else if( action==3 ){ sel_action = "std_rev_diff_sel.php"; }else if( action == 4 ){ sel_action = "std_rev_exercise.php"; isexercise = true; } else if( action == 5 ) { sel_action = "message.php" } if(action <= 3 ){ location =sel_action + "?cdlevel_enc=" + cdlevel_enc + "&cdsubject_enc=" + cdsubject_enc ; }else{ location =sel_action + "?cdlevel_enc=" + cdlevel_enc + "&cdsubject_enc=" + cdsubject_enc + "&tyexercise_enc=" + tyexercise_enc; } document.location = location; } </script> And this is the button code: <input type="button" onclick="redirect_selection(<?php echo $num ?>);" value="Selection by Set" name="btnset" class="button_assess" > <input type="button" onclick="redirect_selection(<?php echo $num ?>);" value="Random Selection" name="btnrandom" class="button_assess"> <input type="button" onclick="redirect_selection(<?php echo $num ?>);" value="Selection by Difficulty" name="btndiff" class="button_assess"> The problem is in if statement, in else condition it only select $num = 1 selection. How to remove this prob.Any ideas Please any help will be appriciated. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/43632-ifelse-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.