1
neda_barna
combo box
  • 2007/9/24 6:46

  • neda_barna

  • Just popping in

  • Posts: 63

  • Since: 2007/9/5 4


i have one combox with this code
$form .= '
           '
._REF_ASSIGN_ALLLIST.'
           '
._REF_LIST_UNIQE.'
           '
._REF_LIST_ALLA.'
             

now i want write if value=A do this work
or if value=B do this work
how can write this code

2
kaotik
Re: combo box
  • 2007/9/24 8:54

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


if ($_POST['referee']=='A')
{
//do something
} elseif ($_POST['referee']=='B')
{
//do something
} elseif ($_POST['referee']=='C')
{
//do something
}


go over to php.net and read about elseif and switch, both of these would work for you.

3
neda_barna
Re: combo box
  • 2007/9/24 9:00

  • neda_barna

  • Just popping in

  • Posts: 63

  • Since: 2007/9/5 4


thx so much

4
script_fu
Re: combo box

The two posts that neda made have helped the garage project.

Thanks to kaotik & dave l

5
neda_barna
Re: combo box
  • 2007/9/24 9:22

  • neda_barna

  • Just popping in

  • Posts: 63

  • Since: 2007/9/5 4


i write this code but dont work
why???????????
$combo '
           
          
           '
._REF_ASSIGN_ALLLIST.'
           '
._REF_LIST_UNIQE.'
           '
._REF_LIST_ALLA.'
             

          
          '
;

echo 
$combo;
echo 
$searchForm;
 
if (
$_POST['referee']=='A')
{
echo 
refereeList'referee''assign'$sidTRUE  );
} elseif (
$_POST['referee']=='B')
{
echo 
"hello";
}

6
kaotik
Re: combo box
  • 2007/9/24 9:33

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


if (isset($_POST['send_exp'])) //Check if submit button was pressed
{
echo 
'button was pressed '//this line is for testing, erase it when your finished
if ($_POST['referee']=='A')
{
echo 
refereeList'referee''assign'$sidTRUE  );
} elseif (
$_POST['referee']=='B')
{
echo 
"hello";
}
}

$combo '
           
          
           '
._REF_ASSIGN_ALLLIST.'
           '
._REF_LIST_UNIQE.'
           '
._REF_LIST_ALLA.'
             
            
            
            
          
          '
;

echo 
$combo;
echo 
$searchForm;


There's a couple of things wrong here:
-Your form didn't have a submit button.
-You need to have a condition to check if an element of your form exists, I normally check if the submit button was pressed:
if (isset($_POST['send_exp']))
-Normally this condition comes before the form.

7
kaotik
Re: combo box
  • 2007/9/24 9:36

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


script_fu: I'm curious about your garage project Did you start this module based on my tutorials?

8
neda_barna
Re: combo box
  • 2007/9/24 9:47

  • neda_barna

  • Just popping in

  • Posts: 63

  • Since: 2007/9/5 4


thx
my problem solved
i forget that i must have submit button
koatik
i have another problem
i have a list that have check box
this code
function refereeList$case$case_next NULL$sid NULL$withcheck FALSE  ){
    
    global 
$query$order$start$limit;

        
  
$referee_r JournalReferee::getAll$queryTRUE$order$limit$start );
    
//echo '
'; print_r( $referee_r ); echo '
'; // !!!!!!!!!! DEBUG !!!!!!!!!!!!!
    
    
$action 'referee.php?case='.$case_next.'&case_pre='.$case.'&order='.$order.'"';
    
//if ( $sid ) { $action.= '&sid='.$sid; }
 
    
$total JournalReferee::getCountAll$query ); // DEBUG!!
    //$total = count( JournalReferee::getAll( $query, FALSE ) );
    

 

        
$content '.$action.'" method="post">
          ';
    if ( 
$withcheck ) {
        
$content.= '';
        }
    
$content.= ''._REF_NAME.'
        '
._REF_FIELD.'
        '
._REF_EMAIL.'
            '
._REF_STATUS;
    
    
// --- Status Description --- Referee's staus desc in brief !    
    
if ( ) {
                } elseif ( 
) {
                } elseif ( 
) {
                } else {
            
$content.= ''._REF_ASSIGN_JOB.' '._REF_CHAR_PIPE.'
                 '
._REF_ASSIGN_EXP.' '._REF_CHAR_PIPE.
                 '
._REF_ASSIGN_FIN.'
';
        }

    
$content.= '';
    
        
$class 'even';

        foreach ( 
$referee_r as $referee ) {

                
$uid $referee->getVar'uid' );
                
$name $referee->getVar'name' );
                
$email $referee->getVar'email' );
                
$status $referee->getStatus();
        
        
$field substr_words$referee->getVar'bio' ), );

        if ( 
) {
                } elseif ( 
) {
        } elseif ( 
) {
        } else {
            
$_status '
            
            
            
            
'.$status'assign' ].' '._REF_CHAR_PIPE. '.$status'expire' ].' '._REF_CHAR_PIPE. '.$status'finish' ].'
'
;
        }
    
                
//$date = formatTimestamp ( $paper->getVar( 'date' ), 's' );
        
$class = ($class == 'odd') ? 'even' 'odd';
                
        
$content.= '';
        if ( 
$withcheck ) {
            
$content.= '.$uid.'"';    
        }
        
$content.= '
                    .$class.'">'.$name.'
                    .$class.'">'.$field.'
            .$class.'">'.$email.'
                    .$class.'">'.$_status.'
            '
;
                
$content.= '';

        }
    
$content.= '';
        if ( 
$withcheck ) {
              
$searchForm '
             '
._REF_ASSIGN_ALLLIST.'
               '
;
                          
$form '

    
     '
._REF_EXP.': 

    '
;

 
    
//$form.=    '  ';
    
     
$form .=    ' ._REF_SAVE.'" />

          
          '
;
    
echo 
$searchForm;
echo 
$form;
        
               
//$content.= '
        //    ';
        
}
    
$content.= '';
    
    return 
$head.$content;
}

now i want if on1 row of list checked
do this code
[code]$word=$_POST['key'];
$word1=$word * 86400;
$query="UPDATE ".$xoopsDB->prefix ( referee )." SET exp_date = exp_date + '$word1' WHERE uid=$uid AND name=$name ";
$xoopsDB->query($query);
if($xoopsDB->query($query)){
echo "Data was correctly inserted into DB!";
}
} [code]
please tell me how can write this code
thx for your help

9
kaotik
Re: combo box
  • 2007/9/24 10:10

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


There are a couple of things wrong.
//Replace:
$xoopsDB->query($query);
if(
$xoopsDB->query($query)){

//with:
$res=$xoopsDB->query($query);
if(
$res){
//Otherwise you are doing 2 database insert's.


Now, checkbox will be returning as an array, so we must treat it as such, it might hold one or various elements.


foreach ($_POST['check'] as $chk)
{
$word=$_POST['key'];
$word1=$word 86400;
$query="UPDATE ".$xoopsDB->prefix referee )." SET exp_date = exp_date + '$word1' WHERE uid='$chk' AND name='$name' ";
$res=$xoopsDB->query($query);
if(
$res){
echo 
"Data was correctly inserted into DB!";
}
}
}

10
neda_barna
Re: combo box
  • 2007/9/24 10:43

  • neda_barna

  • Just popping in

  • Posts: 63

  • Since: 2007/9/5 4


but dosent work
pay attention to:
that i have list of referee
and i want when i check on referee from list
and put number into a textbox
then do a query (update)
note:can i check the chebox and insert a number into a textbox
then click a submit button(for do my query)
did it work or no?

Login

Who's Online

321 user(s) are online (217 user(s) are browsing Support Forums)


Members: 0


Guests: 321


more...

Donat-O-Meter

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

Latest GitHub Commits