blazing_bruce Posted March 25, 2006 Share Posted March 25, 2006 hello all,i have a table named restRID CID1 | 21 | 31 | 42 | 22 | 33 | 23 | 44 | 24 | 3i want to list records which accepts the cards (CID).first i have 4 check boxes in search.php for($i=1;$i<=$total_cards;$i++){$fetch = mysql_fetch_row($pass_cards);$id=$fetch[0];$name = $fetch[1];echo("<input type='checkbox' name='card[]' value='$id' />$name");}in list.phpi want to show the list of records based on check box's valuegetting post values by$checked = $HTTP_POST_VARS['card'];now i want to list all the records which having all the CID values. if i checking the check box 2 and 3 (which is CID)then list.php will show 1,2,4 (RID)i have tried in many ways, but no use.this is wil be a simple MySQL query. please help me. Quote Link to comment Share on other sites More sharing options...
Barand Posted March 26, 2006 Share Posted March 26, 2006 Try[code]$cardList = join (',' , $_POST['card']);$k = count($_POST['card']);$sql = "SELECT RID, COUNT(*) as reccount FROM rest WHERE CID IN ($cardList) GROUP BY RID HAVING reccount = $k";[/code] Quote Link to comment Share on other sites More sharing options...
blazing_bruce Posted March 26, 2006 Author Share Posted March 26, 2006 Thank you Mr.Barand. your query is working now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.