Hello and welcome to our community! Is this your first visit?
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
    Lahore, Pakistan
    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))

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

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

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

    plz help in this regard

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 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:
    <form action="process.php" method="post">
      <select name="selectbox">
        <options />
      <input type="submit" name="submit" value="Submit" />
    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:
    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'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


Posting Permissions

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