Jump to content

Recommended Posts

Hey guys,

 

I want to have a search on my page that will allow the user to select multiple search terms from a check box list. For example, if they were seaching for a mobile phone and the list was..

 

NETWORK

-------------

O2

Vodafone

T Mobile

Three

 

Ho can I determine which ones was selected so I can create a query for the database? If only O2 and Three were selected I'd want my query to be something like...

 


SELECT * FROM phones WHERE network = 'o2' || network = 'three'

 

Link to comment
https://forums.phpfreaks.com/topic/133784-searching-with-check-boxes/
Share on other sites

I see. Would my array to catch them looking something like...

 

<?php 

if(isset($_GET['02'])){$networks[] = "o2"}

if(isset($_GET['meteor'])){$networks[] = "meteor"}

if(isset($_GET['vodafone'])){$networks[] = "vodafone"}

?>

 

something like that anyway?

 

I tried it your way and I'm trying it this way but it just seems to keep printing ARRAY.

 

<?php

if(isset($_POST['o2'])){$network[] = "o2 = 'Yes' ||";}	
if(isset($_POST['meteor'])){$network[] = "meteor = 'Yes' ||"; }
if(isset($_POST['vodafone'])){$network[] = "vodafone = 'Yes'"; }


echo $sql = "SELECT * FROM phones WHERE ".$network."";

?>

 

Just echoed the sql to test and it prints..

 

SELECT * FROM phones WHERE Array

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.