Ok here are the two tables:
store
product_id int(5) NOT NULL default '0'
product varchar(255) NOT NULL default ''
cost int(20) NOT NULL default '0',
desc text NOT NULL
permissions
id int(5) NOT NULL auto_increment
userid int(5) NOT NULL default '0'
product_id int(5) NOT NULL default '0'
$userid is a global variable that is set on login
$sql = "SELECT * FROM store";
$result = mysql_query($sql);
while ($arr = mysql_fetch_array($result)) {
$product_id = $arr['product_id'];
$product_name = $arr['product'];
$product_desc = $arr['desc'];
$product_cost = $arr['cost'];
$sql2 = "SELECT * FROM permissions WHERE userid='$userid'";
$r2 = mysql_query($sql2);
$arr2 = mysql_fetch_array($r2);
$pid = $arr2['product_id'];
?>
<form method="POST" action="?op=store" ENCTYPE="multipart/form-data">
<input type="hidden" name="purchase" value="1">
<input type="hidden" name="userid" value="<?=$userid?>">
<input type="hidden" name="product_id" value="<?=$product_id?>">
<tr bgcolor="<?=$row_color?>">
<td class=contest_small valign=top><?=strtoupper($product_name);?></td>
<td class=contest_small valign=top><?=$product_desc?></td>
<td class=contest_small valign=top><?=$product_cost?></td>
<?
if ($product_id == $pid) {
echo "<td class=contest_small valign=middle>N/A</td>";
} else {
echo "<td class=contest_small valign=middle><input type=submit value=buy></td>";
}
?>
</tr>
</form>
<? } ?>
</table>
</td></tr>
</table>
</form>
<?
}
the problem is that for some reason that when a user has products 1,2,3 purchased, they are still showing for sale in the store