SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot annimal's Avatar
    Join Date
    May 2004
    Location
    london
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $chkval in dropdown

    Hi Guys

    Ivre got this URL which passes a value to a php dropdown
    PHP Code:
    http://website.com/Nativity-Ticket-Booking.php?chkval=4 
    The drop down is like this
    PHP Code:
    <?
    $chkval 
    $_REQUEST['chkval'];
    if(!
    $_POST['chkval']) { 
    if (
    $chkval == 1){ 
    echo
    "
             <select name='select' size='1' class='style1'>
                <option>Friday, 4.45pm - 16th December 2005</option>
    </select>"
    ;
    }if (
    $chkval == 2){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option>Friday, 7.30pm - 16th December 2005</option>
    </select>"
    ;
    }
    if (
    $chkval == 3){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option>Saturday, 4.45pm - 17th December 2005</option>
    </select>"
    ;
    }
    if (
    $chkval == 4){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option>Saturday, 7.30pm - 17th December 2005</option>
    </select>"
    ;
    }
    if (
    $chkval == 5){ 
    echo 
    " <select name='select' size='1' class='style1'>
                 <option>Sunday, 4.45pm - 18th December 2005</option>
    </select>"
    ;
    }
    if (
    $chkval == 6){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option>Monday, 4.45pm - 19th December 2005</option>
    </select>"
    ;
    }
    if (
    $chkval == 7){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option>Monday, 7.30pm - 19th December 2005</option>
    </select>"
    ;
    }
    if (
    $chkval == 8){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option>Tuesday, 4.45pm - 20th December 2005</option>
    </select>"
    ;
    }
    if (
    $chkval == 9){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option>Tuesday, 7.30pm - 20th December 2005</option>
    </select>"
    ;
     
    }
    }
        
    ?>
    Now im able to pull the value out using $select and do what i want with it
    I want to be able to use $chkval to pull back the numeric value when passed in the form.
    any ideas this one is bugging me lol
    im trying to use it like this
    PHP Code:
    $chkval $_REQUEST['chkval'];
     
    include 
    'common.php';
         
    dbConnect();
                 
    $result mysql_query("SELECT seats FROM $zipTable WHERE id='$chkval'");    
        
    $uum mysql_result($result,0,'seats');
        
    $res $Adult+$Child;
        
    $result3 $uum-$res;
        
    $result4 mysql_query("UPDATE $zipTable SET seats = $result3 WHERE id='$chkval'"); 

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    If I understand you correctly, something like this....
    PHP Code:
    if ($chkval == 8){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option value='8'>Tuesday, 4.45pm - 20th December 2005</option>
    </select>"
    ;
    }
    if (
    $chkval == 9){ 
    echo 
    " <select name='select' size='1' class='style1'>
                <option value='9'>Tuesday, 7.30pm - 20th December 2005</option>
    </select>"
    ;


    Cheers

    Mike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Zealot annimal's Avatar
    Join Date
    May 2004
    Location
    london
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks SpikeZ
    Cool will i be able to accses <option value='8'> with $chkval then ?
    edit
    or $option

  4. #4
    SitePoint Zealot annimal's Avatar
    Join Date
    May 2004
    Location
    london
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok ive got the chkval to pass as a numeric value by using a switch command
    on the $chkval but no i need to turn the $options value into a array and pass that to another page any ideas!
    Thanks for any help
    PHP Code:
    <? 
     
    $chkval 
    $_GET['chkval']; 
     
    $option ''
     
    switch(
    $chkval

        case 
    1
            
    $option 'Friday, 4.45pm - 16'
            break; 
        case 
    2
            
    $option 'Friday, 7.30pm - 16'
            break; 
        case 
    3
            
    $option 'Saturday, 4.45pm - 17'
            break; 
        case 
    4
            
    $option 'Saturday, 7.30pm - 17'
            break; 
        case 
    5
            
    $option 'Sunday, 4.45pm - 18'
            break; 
        case 
    6
            
    $option 'Monday, 4.45pm - 19'
            break; 
        case 
    7
            
    $option 'Monday, 7.30pm - 19'
            break; 
        case 
    8
            
    $option 'Tuesday, 4.45pm - 20'
            break; 
        case 
    9
            
    $option 'Tuesday, 7.30pm - 20'
            break; 

     
    $option .= 'th December 2005'
     
    echo 
    '<select name="select" size="1" class="style1"> 
             <option value="' 
    $chkval '">' $option '</option> 
         </select>'

    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •