473,320 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Multiple select values & wordpress

2
Below code is what i found from a search in web.

Suppose i have a taxonomy called Color and terms are Blue, Green, Red, Yellow, White. I want when i select Blue, Green and Red and click submit button, i want to get ALL posts those have Blue OR Green OR Red (OR etc.) taxonomy term on the search results page.

Since the code below is just echoes "Insert Query - Blue, Insert Query - Red ...", is there any way to convert this into a code that in which i can get posts?




Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_POST['clickhere'])) {
  3.     $selected_values = $_POST['color'];
  4.     foreach($selected_values as $key=>$value) {
  5.                 // Insert query comes here.
  6.         echo "Insert Query - ".$value."<br />";
  7.     }
  8.  
  9.     $select_blue = (in_array('1',$selected_values)) ? "selected" : "";
  10.     $select_green = (in_array('2',$selected_values)) ? "selected" : "";
  11.     $select_red = (in_array('3',$selected_values)) ? "selected" : "";
  12.     $select_yellow = (in_array('4',$selected_values)) ? "selected" : "";
  13.     $select_white = (in_array('5',$selected_values)) ? "selected" : "";
  14. }
  15. ?>
  16.  
  17. <form name='testform' action='sometest.php' method='post'>
  18. <select name='color[]' style="border:0px;" size=6 multiple>
  19. <option value='' selected>Select Item</option>
  20. <option value='1' <?php echo $select_blue;?> >Blue</option>
  21. <option value='2'<?php echo $select_green;?> >Green</option>
  22. <option value='3'<?php echo $select_red;?> >Red</option>
  23. <option value='4'<?php echo $select_yellow;?> >Yellow</option>
  24. <option value='5'<?php echo $select_white;?> >White</option>
  25. </select>
  26. <br /><br />
  27. <input type='submit' name='clickhere' value='Click Here' />
  28. </form>
Jun 28 '11 #1
0 1114

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Stephen Witter | last post by:
I have a multiple select list and I am trying to post to a page where I have no option to use the request.form or vbscript to iterate through the control. The page is a sql server reporting...
5
by: johkar | last post by:
This script works fine if all form fields have one value, but what do you do if one of the form fields was a multiple select? Example: status=blue&status=red function getParams() { var...
1
by: Bung | last post by:
I am trying to retrieve selected values from a multiple select object on a page: *** Selection Page *** <form name="theForm"> <select name="numbers" MULITPLE> <option value="1">One</option>...
4
by: cwwilly | last post by:
Hello, Thanks for taking a look at this! Problem: I'm trying to pass multiple dynamic values between a slaveform and a masterform. The problem I'm having is on the slaveform I loop through...
2
by: murraymiken | last post by:
I'm looking to have multiple multiple-select-boxes on a page. But I can only get the contents from the last selected value within a box, via PHP. I've tried numerous methods. What am I doing...
2
by: karups | last post by:
Hi, I've got listbox in my .aspx page where the users can make multiple selection. So, Users can select any number of items in listbox, I have to take value from items and pass it to stored...
3
by: scott | last post by:
Hello all, I am ripping my hair out over this and maybe someone could help. I have a site that has groups and subgroups of those groups that all have int id's. I am trying to have a...
0
by: sundsx | last post by:
Hi, i would sen multiple select to mysql by form, my prb is: file connect.php <?php $user="sundsx"; $pass="password"; $db="testphp"; $val_form=$_POST; $service =$_POST;
2
by: dinkle | last post by:
Hi Y'all, I am pretty new to js and am hitting a few snags. I need to process a multiple select list and pass it onto a PHP script. I can only get the first value in the JS and have no idea how...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.