Jump to content

Using check boxes as part of filter in PHP/SQL


WAMFT1

Recommended Posts

if text then the values need to be escaped with real_escape_string

 

eg

 

$db = new mysqli(HOST,USERNAME,PASSWORD,DATABASE);

$arr = array (
   'Jones',
   "O'Neill",
   'Smith'
);
$list  = "'" . join("','", array_map(array($db,'real_escape_string'), $arr)) . "'";
echo $list;    //--> 'Jones','O\'Neill','Smith'

Link to comment
Share on other sites

Your form method is GET

Your checkboxes are now called SelType

You haven't submitted the query

 

Apart from that ...

 

try

 

$SelType = join(',', array_map('intval', $_GET['SelType']));

$sql = "SELECT * FROM APS WHERE Paycode='ANM' AND Type IN ($SelType) ORDER BY `Date` DESC";  
$result = mysql_query($sql);
  
Link to comment
Share on other sites

I added another field into the SQL to use the int value for querying and print the text on the display. I then wrote into the export query my end to assign 1 to commission, 2 to wealthtrac and 3 to rebate to insert into the online SQL. That way I would have the best of both worlds. 

Link to comment
Share on other sites

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.