View Full Version : problem while access value to other page

09-15-2005, 09:56 AM
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

09-15-2005, 11:13 AM
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).

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.