[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Multiple Criteria Search

Posted on 2013-05-23
3
Medium Priority
?
264 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

649 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