We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,586 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

question

how can i search names according to checkbox values from database table

2
Contributors
1
Reply
1 Hour
Discussion Span
8 Months Ago
Last Updated
2
Views
chanchal.os
Newbie Poster
2 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Exg:

In your Form ..

<input type="checkbox" name="chk[]" value="1" />
<input type="checkbox" name="chk[]" value="2" />
<input type="checkbox" name="chk[]" value="3" />

In action page

<?php
if($_POST['chk']) {
$chekedValues=  array();
$chekedValues = $_POST['chk'];
$append="";
foreach ($chekedValues as $key=>$value) {
            $append.=($key==0) ? 'WHERE ' : 'OR';
            $append.= " db_table_field_name="."'".$value."'";
}

$sqlsearch = mysql_query("SELECT * FROM db_table_name ".$append);

    while ($row = mysql_fetch_array($sqlsearch))
        {

        }
}
?>
Bachov Varghese
Junior Poster
123 posts since Sep 2011
Reputation Points: 41
Solved Threads: 29
Skill Endorsements: 3

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0617 seconds using 2.68MB