...

View Full Version : problem while access value to other page



eshban
09-15-2005, 08: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))
{
$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

Fou-Lu
09-15-2005, 10: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 />
</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
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum