Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP dropdown attributes for virtuemart

Featured Replies

Hi,

 

I've been looking for a way to display virtuemart attributes for a while now and came accross something very close the other day. Its exactly what i've been looking for only i need it in a select form (dropdown) rather than the current submit form its in. Fortunately i only understand basic php and i cant get my head around the code, i've managed to convert the inputs to select boxes only instead of being in a dropdown there under each other like a list. Heres the snippet of code i've modified:

 

//All filters empty		
		if (empty($got_filters) && $product_parameter_line->parameter_name==${'db_v'.$i}->f("parameter_name")  )  {  
						$db3 = new ps_DB;		
						$db3->query("$query_filters AND $variable_parameter_name='$parameter_value'" );	
						$dbtotal = new ps_DB;
						$dbtotal->query(" $query_filters" );	

			if (count($db3->record)!=0) {


				echo '<tr><td><form action="'.$baseurl.'category_id='.$category_id.'&product_type_'.$product_type_id.'_'.$parameter_name.'_comp=in&';
				echo 'product_type_'.$product_type_id.'_'.$parameter_name.'[]='.$field.'" method="post" id="postfilter'.$i.'">';
				echo '<input type="hidden" name="url_before_filter" value="'.$current_url.'" /> ';
				echo '<select class="parameter">';
				echo '<option class="parameter" name="verstuur $i." value="'.$parameter_value.' '.$parameter_unit.' ('.count($db3->record).')" </option>';
				echo '</select>';	
				echo '<input type="submit" class="parameter"';
				echo $i.'" value="'.$parameter_value.' '.$parameter_unit.' ('.count($db3->record).')" /></form></td></tr>';


			}	
			break;
		}

 

Notice i've echo'ed the input types ie select and option, im thinking this is where im going wrong. Perhaps i need to list them using foreach $ ?

 

I've also attached a txt file containing the full code for anyone that wishes to look.

 

Any advice here would be appreciated.

 

Thanks,

 

Mark

code.txt

  • Author

I've managed to get a little further with this but still the select inputs are listed below another and not in a dropdown ... heres my updated code.

 

			if (count($db3->record)!=0) {
				echo '<tr><td style="padding:0"><form action="'.$baseurl.'category_id='.$category_id.'&product_type_'.$product_type_id.'_'.$parameter_name.'_comp=in&';
				echo 'product_type_'.$product_type_id.'_'.$parameter_name.'[]='.$field.'" method="post" id="postfilter'.$i.'">';
				echo '<input type="hidden" name="url_before_filter" value="'.$current_url.'" /> ';
				echo '<select name="'.$parameter_name.'"> ';
                                       foreach($fields as $field) { 
				echo '<option name="verstuur '.$i.'" value="'.$parameter_value.' '.$parameter_unit.' ('.count($db3->record).')" >'.$parameter_value.'</option>';
                                       }
				echo '</select> ';
				echo '<input type="submit" class="parameter" name="verstuur" />';
				echo '</form></td></tr>';	
			}	
			break;
		}

 

If someone could just have a quick look at the code above and tell me where im going wrong that would be brilliant. I've added a foreach command in there which has definately done some good but it still doesnt seem to be listing an input for each. You can see how it comes out here, see left hand side under the title 'product filter'.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.