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. Link to comment https://forums.phpfreaks.com/topic/5802-solved-mysql-table-searching-harder-a-bit/ 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] Link to comment https://forums.phpfreaks.com/topic/5802-solved-mysql-table-searching-harder-a-bit/#findComment-20810 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. Link to comment https://forums.phpfreaks.com/topic/5802-solved-mysql-table-searching-harder-a-bit/#findComment-20897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.