?
Solved

Multiple Criteria Search

Posted on 2013-05-23
3
Medium Priority
?
263 Views
Last Modified: 2013-05-23
I have a table that includes Street, City, State.  If I have a searchbox on a website thats asks for Street, City, State in this format seperated by commas, how do I extract the three values to search the table?
0
Comment
Question by:DS928
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
Mark Brady earned 2000 total points
ID: 39192615
Very easy to do with php. Assuming your form will post that csv (comma separated values) to the script you would do this. I am assuming you already have a database connection open before running my code (else the mysql_real_escape_string() part won't work)

<?php

$address = isset($_POST['address']) ? $_POST['address'] : null;

if (!is_null($address)) {
     // we need to explode them into separate values
     $address = array_map('trim', explode(',' $address));

    // now because you know the order of them you can pick them out like this

    $street = mysql_real_escape_string($address[0]);
    $city = mysql_real_escape_string($address[1]);
    $state = mysql_real_escape_string($address[2]);

// now you can insert them into your database safely

}

?>

Open in new window

0
 

Author Closing Comment

by:DS928
ID: 39192694
Thank you very much!  I was sweating bullets there for a moment!
0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 39193210
You're welcome
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question