473,788 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String as a URL variable - split to query recordset

7 New Member
I'd like to pass a multi-word string as a variable to a page which then splits the string into seperate words. After this I want to create a recordset using each of the words in the query on the same field eg:

the url would look like this:

mypage1.php?sea rch=apple banana

where fruit LIKE apple OR fruit LIKE banana (in this example)

I've been bothering this for a while now and can't seem to get it to work. I'm using Dreamweaver 8

Any help would be greatly appreciated.
Nov 14 '07 #1
3 2167
ak1dnar
1,584 Recognized Expert Top Contributor
Nothing to do with dreamweaver here, You have to use a script like this. Check this out please:

split_url_strin g.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $OriginalQuery = "SELECT col_names FROM table";
  3. $string = array();
  4. $where = "";
  5. if (isset($_GET['search']) AND !empty($_GET['search'])) {
  6.   $URLString=explode(" ",$_GET['search']);
  7.   foreach($URLString as $key){
  8.   $string[] = " fruit LIKE $key "; // Hope You Know the Logic use to "LIKE"  :D
  9.   }
  10.   }
  11. if(!empty($string)){
  12. $where = " WHERE ".implode("OR", $string);
  13. }
  14. echo $OriginalQuery.$where; 
  15. ?>
  16.  
Once you called to the page like in way of this format:
http://localhost/tut/split_url_strin g.php?search=ba nana apple
outputs:
SELECT col_names FROM table WHERE fruit LIKE banana OR fruit LIKE apple
Nov 14 '07 #2
Vlinder
7 New Member
Many thanks. Had to tinker around with it a bit but got it working in the end. Most importantly, I've learned a few things.

Again, thank.
Nov 14 '07 #3
ak1dnar
1,584 Recognized Expert Top Contributor
Many thanks. Had to tinker around with it a bit but got it working in the end. Most importantly, I've learned a few things.

Again, thank.
Glad I could help ! post back to the forum any time.
Good luck! :)
Nov 14 '07 #4

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

Similar topics

7
2388
by: Jim Adamson | last post by:
I have created a web page that receives names and values from a URL string of another page e.g. http://hostname/resolve?sublibrary=JMLibrary&collection=Elton&shelfmark=LM 36TY ... and decodes the names/values from the ? onwards, doing all the seperation of the ampersands. Here is the "decoder" that I found at http://www.tek-tips.com/faqs.cfm?fid=5442
3
7451
by: Dr. Oz | last post by:
Hi, I am trying to read in a query string from one page and build a link to another page based on the query string. Here's the code I am using to read in the query string: <script "text/javascript"> function getQueryVariable(variable) { var query = window.location.search.substring(1);
3
2532
by: ethoemmes | last post by:
I have used the import class module from http://www.mvps.org/access/modules/mdl0057.htm. This reads my text file into a string called myString. I am trying to append this string into table tblTEMPVendors. The string is tab delimited. I am trying to use the code below to do this but I need some help - How do I loop through the string if this was a recordset I know i would use do while not rs.eof but I can't get the syntax for a string...
9
23712
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the "improvements", but maybe someone here can point me in the right direction... First, it looks like asp.net will automatically read and recognize query strings encoded in utf8 and 16-bit unicode, only the latter is some mutant, non-standard...
1
3515
by: johnpremi | last post by:
Hi there, I have to pass a query string parameter in my Web Config for loading a URL. We have two environments (production and devlopment) and MonitorURL needs to be changed when the deployment is done. In production this variable will be http://servername:8080/MONITOR?query=asd&query2=adsas;http://servername:8080/MONITOR?query=asd&query2=adsas In this we need to get two strings by parsing the variable. But when I try to give this variable...
1
3175
by: sadiewms | last post by:
Hi! I'm trying to loop through records in a table, split the contents and insert each subsequent string in the array into a new table. I need to determine how to cast the current record in the record set as a string. I'm very very new to access and VB and any help would be greatly appreciated! Below is what I have so far (see question marks in code...):
5
5889
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public function returns a long string. This works. 2. A query has a calculated field based on the custom function above. This works when the query is run directly.
3
5617
by: Skip | last post by:
OK, I'm a novice in JS but have lots of coding experience. I am trying to accomplish something that would seem somewhat simple - BUT IT'S NOT. I have a basic window that calls another window with window.open and passes in 1 value using a querystring i.e., www.myhome.com/mypage?video=BAK-Extension Now when the window opens, I can capture the passed value in a JS function. But if I want to use that in the body of the HTML in a
2
5642
by: I Hate My Computer | last post by:
I am using frames on a website. The title link on the title page adds a query string. The link goes to a page with two rows the second has two columns. I want the right column to be changed depending on what the query string is. I have the script to parse the query string here: function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair =...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10118
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.