Jump to content

Archived

This topic is now archived and is closed to further replies.

blazing_bruce

**SOLVED** mysql table searching. harder a bit.

Recommended Posts

hello all,
i have a table named rest

RID CID
1 | 2
1 | 3
1 | 4
2 | 2
2 | 3
3 | 2
3 | 4
4 | 2
4 | 3
i 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.php
i want to show the list of records based on check box's value

getting 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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

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.