Jump to content

Select Options Disappear On Change


son

Recommended Posts

I have a drop down that displays the available options for a product. Each time the select option is changed all options other than currently displayed item disappear from drop down. Why is that? The code is:

 if ($style != 2){ // size options$sq = "SELECT style_id, online_name, ns_id FROM mattresses WHERE ns_id='$nsproduct' OR parent='$nsproduct'";$sr = mysqli_query ($dbc, $sq) or die ('sorry');if ((mysqli_num_rows($sr) > 0)) {echo "<p class=\"dimHead\" style=\"clear: left; margin:15px 0 2px 0;\">Choose your size</p>";echo "<select onchange=\"window.location.href=this.value\">";echo "<option>Please select...</option>";	while (list($style_id, $name, $nsid, $size) = mysqli_fetch_array($sr, MYSQLI_NUM)) 	{	echo "<option value=\"mattresses_product.php?style=$style_id&id=$nsid\">$name</option>";	}echo "</select>";}}

Many thanks,Son

Link to comment
Share on other sites

Because you are only selecting the options for the current nsproduct in your SELECT query...

Link to comment
Share on other sites

Because you are only selecting the options for the current nsproduct in your SELECT query...
Also have at top of script:
if (isset($_GET['id'])) {	// if yes assign to $nsproduct	$nsproduct = (int) $_GET['id'];	// make sure the id is available	$query = "SELECT style_id, parent, ns_id FROM mattresses WHERE ns_id='$nsproduct'";	$result = mysqli_query ($dbc, $query) or die ('sorry');	if (mysqli_num_rows($result) == 0) 	{ 

This gets $nsproduct when new selection is made...Son

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...