Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lahore, Pakistan
    Posts
    150
    Thanks
    2
    Thanked 0 Times in 0 Posts

    problem while access value to other page

    here is a simple code, which retrieves size from database. Size is stored in string format which is "M-L-XL-XXL".
    i use the explode function, and store all the sizes in combox like M, L , XL and XXL are seperatley.

    i want that when i press the submit button, then it will transfer that values of combox, which i selected. kindly help me in this regard.

    here is the code


    $query = mysql_query("Select * from newproductinfo where pid=$pageid",$db) or die ("Error");


    while ($result = mysql_fetch_array($query))
    {
    $size=$result['size'];
    }

    echo"Size: <select name='select'>";
    $sizes = explode("-",$size);

    if($sizes[0]<>"")
    {
    echo"<option value='M'>$sizes[0]</option>";

    }
    if($sizes[1]<>"")
    {
    echo"<option value='L'>$sizes[1]</option>";
    // echo"<input type='hidden' value='L' name='size'>";
    }
    if($sizes[2]<>"")
    {
    echo"<option value='XL'>$sizes[2]</option>";
    }
    if($sizes[3]<>"")
    {
    echo"<option value='XXL'>$sizes[3]</option>";
    }
    echo"</select>";

    plz help in this regard

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I responded to your other thread about creating these option values easily.
    Also, please wrap your code in [php] tags so its easily readable.
    With this, you need to do something with the values selected. Create a form:
    Code:
    <form action="process.php" method="post">
      <select name="selectbox">
        <options />
      </select>
      <input type="submit" name="submit" value="Submit" />
    </form>
    or whatever you need.
    Process.php then retains the values of these fields within the $_POST superglobal. Always refer to this as a $_POST field -> never rely on register_globals bein 'on' as most hosting companies are defaulting these to 'off' (which is good).
    PHP Code:
    <?php
    echo $_POST['selectbox'];
    ?>
    Your output would be whatever has been selected on the form. Watch out for evaluations though, textfields will get you as isset() always returns true, whether the fields are populated or not.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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