Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Your site has saved me hours of work that I cannot begin to express my satisfaction..."

Geography

Where in the world do Tek-Tips members come from?
PCHomepage (Programmer)
10 Aug 12 15:26
This little bit of code that I've been using for quite a while works fine for multiple numeric POSTS, which is what I generally have, but now I have some that are text. However, I can't seem to work out how to surround them with single quotes so that they will work in a query. Ideas?

CODE

if ($_POST['Segment3']) {
	if (count($_POST['Segment3']) > 0) {
		$Where .= "AND Segment3 = ";
		$Where .= implode(" OR Segment3 = ", $_POST['Segment3']);	
		$Where .= " ";
	}
} 
jpadie (TechnicalUser)
10 Aug 12 18:43

CODE

function enquote($string){
 return "'" . mysql_real_escape_string($string) . "'";
}
if ($_POST['Segment3']) {
	if (count($_POST['Segment3']) > 0) {
		$Where .= "AND Segment3 IN ( ";
		$Where .= implode(",", array_map('enquote',$_POST['Segment3']));	
		$Where .= ")";
	}
} 
PCHomepage (Programmer)
10 Aug 12 19:37
So elegant and simple, thanks!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close