I'm not using session_register()
the full code to this:
SESSIONS ( take note that 'product_name' is irrelevant to the product_main select menu)
Code: Select all
<?php
session_start();
if (isset($_POST['product_name'] )) {
$_SESSION['product_name'] = $_POST['product_name'];
$_SESSION['quantity1'] = $_POST['quantity1'];
}
?>
The Select menu (with a history session to save user selected options) :
Code: Select all
<?php
//select menu product_main
function makeSelectMenu($menuName1, $options1, $chosen1) {
$list1 = '';
foreach
($options1 as $option1 => $text1) {
$selected1 = ($chosen1 == $option1) ? ' selected="selected"' : '';
$list1 .= " <option value=\"$option1\"$selected1>$text1</option>\n";
}
return "\n<select name=\"$menuName1\" STYLE=\"width: 110 px\" id=\"$menuName1\">\n$list1</select>\n";
}
session_start();
$options1 = array(
'' => 'Please Select ',
'1' => '500',
'2 ' => '1000',
'3 ' => '1500',
'4 ' => '2000',
'5 ' => '2500',
'6 ' => '3000',
'7 ' => '3500',
'8 ' => '4000',
'9 ' => '4500',
'10 ' => '5000',
'11 ' => '6000',
'12 ' => '7000',
'13 ' => '8000',
'14 ' => '9000',
'15 ' => '10000',
);
$menuName1 = 'product_main';
$chosen1 = '';
if (isSet($_POST[$menuName1])) $_SESSION[$menuName1] = $_POST[$menuName1];
if (isSet($_SESSION[$menuName1])) $chosen1 = $_SESSION[$menuName1];
$selectMenu1 = makeSelectMenu($menuName1, $options1, $chosen1);
?>
The call to the database:
Code: Select all
<?php
// db query fetch for quantity, baseprice , weight.
if(isset($_POST['product_main']))
{
$sql = "SELECT quantity, baseprice, weight FROM b1_product WHERE id = " . $_POST['product_main'];
$res = mysql_query($sql);
$row = mysql_fetch_assoc($res);
$quantity = $row['quantity'];
$baseprice = $row['baseprice'];
$weight = $row['weight'];
}
?>
Turn quantity data into $variable for sh8ts and giggles:
All that will spit out a select menu.
When you make selection, it takes that options value="" and uses it to search that id number in database.
I have 7 select menus like that in total, but edited them out of this for space.
It all works, but im getting that Warning message:
Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3....blah blah blah