1
neda_barna
working with combo box and switch
  • 2007/10/6 5:17

  • neda_barna

  • Just popping in

  • Posts: 63

  • Since: 2007/9/5 4


hi all
i have this code
that have one combobox and switch and case
but when i chose a combobox this working and case main working
but case update dont work please view my code and tell me why the case update dont work
$combo '<form action="extended_expire.php" method="post">
           <table class="eleHead"><tr>
          <td nowrap><select name="referee">
           <option selected>_________ </option>
           <option  value="A" >'
._REF_LIST_ALLA.'</option>
           <option  value="B" >'
._REF_LIST_KOL.'</option>
           <option value="C">'
._REF_LIST_REF.'</option>
             </select></td>'
;
 
$combo .='<td nowrap> <input type="submit" class="formButton" name="go" value="'._REF_BUTTON_GO.'" /></td>
          </tr></table>
          </form>'
;

echo 
$combo;

elseif ($_POST['referee']=='C')
{







switch ( 
$case ) {

case 
'main':
    
echo 
$w;
/////////////kodom ghesmat ra dashte bashim masalan ghesmate reeferee
     
$query ="status='REFEREE'";

    if ( 
is_http_var'search' ) ) {

        
$tid is_http_var'tid' ) ? get_http_var'tid' ) : NULL;

        
$sid is_http_var'sid' ) ? get_http_var'sid' ) : NULL;

        
$key is_http_var'key' ) ? get_http_var'key' ) : NULL;

        

        

        }

        

    

    

    
$caption = !empty( $caption ) ? $caption _REF_LIST_REF;

    

    
$where_r trim$query ) ? preg_split "/[,]+/"trim$query ) ) : NULL// query string must be comma seperated 

    //echo '<pre>'; print_r( $where_r ); echo '</pre>'; // !!!!!!!!!! DEBUG !!!!!!!!!!!!!

    

    
$order is_http_var'order' ) ? get_http_var'order' ) : "date";

    
$order_pre is_http_var'order_pre' ) ? get_http_var'order_pre' ) : "";

    
$dir = ( $isDir OR $isSec ) ? 'DESC' 'ASC';

    
$order makeOrder $order$order_pre$dir );

    
$order is_http_var'order_force' ) ? get_http_var'order_force' ) : $order;

    
$start is_http_var'start' ) ? get_http_var'start' ) : 0;

    
$start = ( $start ) ? $start;

    
$limit $xoopsModuleConfig'list_rows' ];



    
$op $op $op 'AND';

    

if ( 
is_array$categoryArr ) and count $categoryArr ) ) {

        foreach ( 
$categoryArr as $cat )

            
$categoryCriteriaArr[] = "category = '$cat'";

        
$categoryCriteria ' ( '.implode(' OR ',$categoryCriteriaArr).' ) ';



        if ( 
count$where_r ) )

            
$whereStr ' ( '.implode' '.$op.' '$where_r ).' ) ';

            
$where_r = array( $whereStr$categoryCriteria );

            
$op 'AND';

            

        unset( 
$whereStr );

        unset( 
$categoryCriteriaArr );

        unset( 
$categoryCriteria );

}



    
$papers RefereePaper::getAll$where_rTRUE$order$limit$start$op );

    
$total RefereePaper::getAll$where_r'COUNT'$order00$op );

        
$next_start $start $limit;

        
$back_start $start $limit;

    
$pages ceil$total $limit );

    
$page ceil( ( $start ) / $limit );

    

    
$categoriesArr JournalUser::getCategories();

    

    

        

    
$caption '<table>

            <tr class="head"><td>'
.$caption.'</td><td>&nbsp;</td><td>'._REF_STAT_COUNT.' '.$total.'</td></tr>

        </table>'
;

    

    

    

    
$arrows NULL;

    if ( 
$total $limit ) {

        
$arrows.= '<center class="arrows"><table dir="ltr"><tr><td width="20%"></td><td>';

                if ( 
$start ) {

                                    
$arrows .= '<form action="extended_expire.php">

        <input type="hidden" name="case" value="'
.$case.'" />
                <input type="hidden" name="w" value="'
.$w.'" />

        <input type="hidden" name="query" value="'
.$query.'" />

        <input type="hidden" name="order_force" value="'
.$order.'" />

        <input type="hidden" name="start" value="'
.$back_start.'" />

        <input type="hidden" name="op" value="'
.$op.'" />

        <input type="hidden" name="category" value="'
.htmlspecialchars  $category ).'" />

        <input type="hidden" name="filter" value="TRUE" />

        <input type="hidden" name="filter_var" value="'
.$filter_var.'" />

        <input type="hidden" name="filter_op" value="'
.$filter_op.'" />

        <input type="hidden" name="filter_value" value="'
.$filter_value.'" />

        <button type="submit"><img src="'
.REFER_URL.'/images/back_on.png"></button>

        </form>'
;

                       

                } else {

                        
$arrows.= '<img src="'.REFER_URL.'/images/back_off.png">';

                }

                
$arrows.= '</td><td width="50%" nowrap><center>'

            
._REF_STAT_PAGE.' '.$page.' '._REF_STAT_OF.' '.$pages

            
.'<br /> <table><tr><td width="50%"></td>';

        for( 
$myCounter max(1$page 5); $myCounter <= min($pages$page 5); $myCounter++ )

        {

            
$arrows .= '<td>';

            if( 
$page == $myCounter )

                
$arrows .= '<button><b> '.$myCounter.' </b></button>';

            else

                
$arrows .= '<form action="extended_expire.php">

                <input type="hidden" name="case" value="'
.$case.'" />
 <input type="hidden" name="w" value="'
.$w.'" />

                <input type="hidden" name="query" value="'
.$query.'" />

                <input type="hidden" name="order_force" value="'
.$order.'" />

                <input type="hidden" name="start" value="'
.(($myCounter 1)*$limit).'" />

                <input type="hidden" name="op" value="'
.$op.'" />

                <input type="hidden" name="category" value="'
.htmlspecialchars  $category ).'" />

                <input type="hidden" name="filter" value="TRUE" />

                <input type="hidden" name="filter_var" value="'
.$filter_var.'" />

                <input type="hidden" name="filter_op" value="'
.$filter_op.'" />

                <input type="hidden" name="filter_value" value="'
.$filter_value.'" />

                <input type="submit" name="submit" value="'
.$myCounter.'" />

                </form>'
;

            
$arrows .= '</td>';

        }

        
$arrows .= '<td width="50%"></td></tr></table></center></td><td>';

                if ( 
$total $next_start ) {

                                
$arrows .= '<form action="extended_expire.php">

            <input type="hidden" name="case" value="'
.$case.'" />
<input type="hidden" name="w" value="'
.$w.'" />

                   <input type="hidden" name="query" value="'
.$query.'" />

               <input type="hidden" name="order_force" value="'
.$order.'" />

               <input type="hidden" name="start" value="'
.$next_start.'" />

               <input type="hidden" name="op" value="'
.$op.'" />

               <input type="hidden" name="category" value="'
.htmlspecialchars  $category ).'" />

            <input type="hidden" name="filter" value="TRUE" />

               <input type="hidden" name="filter_var" value="'
.$filter_var.'" />

            <input type="hidden" name="filter_op" value="'
.$filter_op.'" />

            <input type="hidden" name="filter_value" value="'
.$filter_value.'" />

            <button type="submit"><img src="'
.REFER_URL.'/images/next_on.png"></button>

                                                </form>'
;

                                                     

                } else {

                        
$arrows.= '<img src="'.REFER_URL.'/images/next_off.png">';

                }

                
$arrows.= '</td><td width="20%"></td></tr></table></center>';

    }

        

    
$list '<form action="extended_expire.php" method="post">

    <table><tr><td></td>

    <td class="head"><a href="extended_expire.php?case='
.$case.'&order=sid&order_pre='.$order.'&start='.$start.'

        &query_pre='
.$query.'&op='.$op.'">'._REF_ID.'</a></td>

    <td class="head"><a href="extended_expire.php?case='
.$case.'&order=title&order_pre='.$order.'&start='.$start.'

            &query_pre='
.$query.'&op='.$op.'">'._REF_TITLE.'</a></td>

    <td class="head"><a href="extended_expire.php?case='
.$case.'&order=author&order_pre='.$order.'&start='.$start.'

            &query_pre='
.$query.'&op='.$op.'">'._REF_AUTHORS.'</a></td>

    <td class="head"><a href="extended_expire.php?case='
.$case.'&order=date&order_pre='.$order.'&start='.$start.'

            &query_pre='
.$query.'&op='.$op.'">'._REF_DATE.'</a></td>

    <td class="head"><a href="extended_expire.php?case='
.$case.'&order=status&order_pre='.$order.'&start='.$start.'

            &query_pre='
.$query.'&op='.$op.'">'._REF_STATUS.'</a></td>

        <td class="head" nowrap>'
._REF_RECORD_STAT.'<br />

                    <div style="font-size: 8px;">'

                    
.' <font color="#1212ff">'._REF_RECORD_STAT_INREV.'</font> |

                   <font color="#12ff12">    '
._REF_RECORD_STAT_ACCPT.'</font> |

                  <font color="#ff1212"> '
._REF_RECORD_STAT_REJ.'</font> |

                 <font color="#ffff00"> '    
._REF_RECORD_STAT_EXPD.'</font> |

                <font color="#000000"> '
._REF_RECORD_STAT_TOT.' </font>

                </div>

    </td>

    </tr>'
;

    

    
$class 'even';

    

    foreach ( 
$papers as $paper ){

        

        
$sid $paper->getVar'sid' );

        
$title substr_words $myts->makeTboxData4Show$paper->getVar'title' ) ), );

            
$authors substr_words $paper->getAuthors() );

            
$date formatTimestamp $paper->getVar'date' ), 's' );

            
$status strtoupper$paper->getVar'status' ) );



        
$class = ($class == 'odd') ? 'even' 'odd';

        

        
$STATUS constant'_REF_STATUS_'.strtoupper$status ) );

        

        

        

    

        

        
$list.= '<tr>

        <td class="head"><input type="checkbox" name="check[]" value="'
.$sid.'"</td>

        <td class="'
.$class.'">'.$sid.'</td>

        <td class="'
.$class.'">'.$title.'</td>

        <td class="'
.$class.'">'.$authors.'</td>

        <td class="'
.$class.'" nowrap>'.$date.'</td>

        <td class="'
.$class.'" nowrap>'.$STATUS.'</td>';

        

        
$criteria_r = array();

        
$criteria_r[] = 'sid = '.$sid;

        
$records RefereeRecord::getAll($criteria_rTRUE);

        
$expired 0;

        
$accepted 0;

        
$rejected 0;

        
$inreview 0;

        
$countAll count$records );

        

        
$list .= '<td class="'.$class.'" nowrap >&nbsp;

            <font color="#1212ff">'
.$inreview.'</font>&nbsp;&nbsp;|&nbsp;&nbsp;

            <font color="#12ff12">'
.$accepted.'</font>&nbsp;&nbsp;|&nbsp;&nbsp;

            <font color="#ff1212">'
.$rejected.'</font>&nbsp;&nbsp;|&nbsp;&nbsp;

            <font color="#ffff00">'
.$expired.'</font>&nbsp;&nbsp;|&nbsp;&nbsp;

            <font color="#000000">'
.$countAll.'</font>&nbsp;</td>';


            

        
$list .= '</tr>';


                    

    }
     

    
$list.= '<tr><td>&nbsp;</td></tr><tr><td></td><td class="">
                <input type="hidden" name="order_pre" value="'
.$order.'">

        <input type="hidden" name="case_pre" value="'
.$case.'">

        <input type="hidden" name="case" value="update">
<input type="hidden" name="w" value="'
.$w.'" />
                </td></table>

        <table>

        <td >'
._REF_EXP.':<input type="text" name="key2" value="" size="20" ></td>

        <tr><td><input type="submit" class="formButton" name="update" value="'
._REF_SAVE.'"class="update"></td></tr>

        </td></table></form>'
;

    

    
/*  Generating Output :) */

    

    

    
echo '<br />';

        echo 
$caption;

    echo 
'<br />';

    echo 
$arrows;

    echo 
'<br />';

    echo 
$list;

    echo 
'<br />';

    echo 
$arrows;     


break;

case 
'update':

    

    

    
$check = array ( );

    
$count 0;

        
$case_pre is_http_var'case_pre' ) ? get_http_var'case_pre' ) : 'main';

        
$check     is_http_var'check' ) ? get_http_var'check' ) : array ( );

    

    foreach ( 
$_POST['check'] as $chk1 ) {

echo 
"hello";

$word1=$_POST['key2'];
$word2=$word 86400;
$query2="UPDATE ".$xoopsDB->prefix referee )." SET exp_date = exp_date + '$word2' WHERE sid='.$chk1.'  ";
$xoopsDB->query($query2);
$count++;

    }

        

    if ( 
$count ) {

        
redirect_header REFER_URL."/extended_expire.php?case=".$case_pre2$count." "._REF_SAVE1 );

    } else {

        
redirect_header REFER_URL."/extended_expire.php?case=".$case_pre2_REF_SAVE_NOPAPER );

    }



    break;



}

}

2
Catzwolf
Re: working with combo box and switch
  • 2007/10/6 13:32

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Hiya,

I have looked over your code and I can see one small issue that could be the source of your problem.

You have an if statement that uses your post var (referee) and in side that if statement you have two 'cases' but I do not see where you have defined the '$case' switch for them. So the scipt just runs right by the two case statements (ignoring them).

You need to tell the script which case statement to use. either 'main' or 'main' using the $case var (Seems that is empty by your script)

Catz

Login

Who's Online

140 user(s) are online (101 user(s) are browsing Support Forums)


Members: 0


Guests: 140


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits