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
le="color: #000000"><?php $form .= '<td nowrap><select name="referee"> <option value="A">'._REF_ASSIGN_ALLLIST.'</option> <option value="B">'._REF_LIST_UNIQE.'</option> <option value="C">'._REF_LIST_ALLA.'</option> </select></td>

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


le="color: #000000"><?php 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???????????
le="color: #000000"><?php $combo = '<form action="extended_expire.php" method="post"> <table class="eleHead"><tr> <td nowrap><select name="referee"> <option value="A">'._REF_ASSIGN_ALLLIST.'</option> <option value="B">'._REF_LIST_UNIQE.'</option> <option value="C">'._REF_LIST_ALLA.'</option> </select></td> </tr></table> </form>'; echo $combo; echo $searchForm; if ($_POST['referee']=='A') { echo refereeList( 'referee', 'assign', $sid, TRUE ); } 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


le="color: #000000"><?php if (isset($_POST['send_exp'])) //Check if submit button was pressed { echo 'button was pressed <br />'; //this line is for testing, erase it when your finished if ($_POST['referee']=='A') { echo refereeList( 'referee', 'assign', $sid, TRUE ); } elseif ($_POST['referee']=='B') { echo "hello"; } } $combo = '<form action="extended_expire.php" method="post"> <table class="eleHead"><tr> <td nowrap><select name="referee"> <option value="A">'._REF_ASSIGN_ALLLIST.'</option> <option value="B">'._REF_LIST_UNIQE.'</option> <option value="C">'._REF_LIST_ALLA.'</option> </select></td> <tr><td> <input type="submit" name="send_exp" value="Submit" /> </td> </tr></table> </form>'; 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
le="color: #000000"><?php function refereeList( $case, $case_next = NULL, $sid = NULL, $withcheck = FALSE ){ global $query, $order, $start, $limit; $referee_r = JournalReferee::getAll( $query, TRUE, $order, $limit, $start ); //echo '<pre>'; print_r( $referee_r ); echo '</pre>'; // !!!!!!!!!! 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 = '<form action="'.$action.'" method="post"> <table><tr>'; if ( $withcheck ) { $content.= '<td></td>'; } $content.= '<td class="head">'._REF_NAME.'</td> <td class="head">'._REF_FIELD.'</td> <td class="head">'._REF_EMAIL.'</td> <td class="head" nowrap>'._REF_STATUS; // --- Status Description --- Referee's staus desc in brief ! if ( 0 ) { } elseif ( 0 ) { } elseif ( 0 ) { } else { $content.= '<br /><small><sup><font color="#AAAA22">'._REF_ASSIGN_JOB.'</font> '._REF_CHAR_PIPE.' <font color="#CC2222">'._REF_ASSIGN_EXP.'</font> '._REF_CHAR_PIPE.' <font color="#22AA22">'._REF_ASSIGN_FIN.'</font></sup></small>'; } $content.= '</td></tr>'; $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' ), 5 ); if ( 0 ) { } elseif ( 0 ) { } elseif ( 0 ) { } else { $_status = '<table border="0" ><tr> <td><b><font color="#AAAA22">'.$status[ 'assign' ].'</font></b></td><td> '._REF_CHAR_PIPE.' </td> <td><b><font color="#CC2222">'.$status[ 'expire' ].'</font></b></td><td> '._REF_CHAR_PIPE.' </td> <td><b><font color="#22AA22">'.$status[ 'finish' ].'</font></b></td> </tr></table>'; } //$date = formatTimestamp ( $paper->getVar( 'date' ), 's' ); $class = ($class == 'odd') ? 'even' : 'odd'; $content.= '<tr>'; if ( $withcheck ) { $content.= '<td class="head"><input type="checkbox" name="check[]" value="'.$uid.'"</td>'; } $content.= ' <td class="'.$class.'">'.$name.'</td> <td class="'.$class.'">'.$field.'</td> <td class="'.$class.'">'.$email.'</td> <td class="'.$class.'">'.$_status.'</td> '; $content.= '</tr>'; } $content.= '</table><br />'; if ( $withcheck ) { $searchForm = '<table border="0" class="listHead"><tr> <td nowrap>'._REF_ASSIGN_ALLLIST.'</td> </tr></table>'; $form = '<form action="extended_expire.php" method="post"> <table class="eleHead"><tr> <td nowrap> '._REF_EXP.': <input type="text" name="key" value="" size="20" /></td> </tr><tr>'; //$form.= '<td>&nbsp;</td></tr><tr><td colspan="1" nowrap>&nbsp;</td>'; $form .= '<td nowrap> <input type="submit" class="formButton" name="search" value="'._REF_SAVE.'" /></td> </tr></table> </form>'; echo $searchForm; echo $form; //$content.= '<input type="hidden" name="sid" value="'.$sid.'"> // <input type="submit" class="formButton" name="assign" value="'._REF_BUTTON_ASSIGN.'">'; } $content.= '</form><br />'; 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.
le="color: #000000"><?php //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.


le="color: #000000"><?php 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

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!