mediabob Posted January 6, 2008 Share Posted January 6, 2008 I have a question about the best way to do this. I have a web site where you can put someone on an "invite" list, now when a person posts content only people on this "invite" list can view the content. All of the "invites" are stored in the same table with just the member numbers for the poster and the invited people being changed. So my question is, when the page is loaded, what would be the best way to check the database to see if the member number of the person viewing the page is in the "invite" table?? So for example if your member # is 1202, and member # 1504 posted some content it would scan the database for member # 1202 on the invite list of member # 1504. I hope I am being clear about what I am saying here ??? Link to comment https://forums.phpfreaks.com/topic/84777-solved-help-with-db-query/ Share on other sites More sharing options...
GingerRobot Posted January 6, 2008 Share Posted January 6, 2008 Something like this should do the trick: <?php $id1 = $_SESSION['id']; //im assuming you have the currently logged in user's in stored in a session? $id2 = $_GET['id']; //and the user ID of the posted content in the $_GET array? $sql = "SELECT COUNT(*) FROM tbl WHERE col1=$id1 AND col2=$id2"; $result = mysql_query($sql) or die(mysql_error()); $num = mysql_result($result,0); if($num != 1){ echo 'You are not authorised to view this!'; exit; } //continue with page ?> Link to comment https://forums.phpfreaks.com/topic/84777-solved-help-with-db-query/#findComment-432072 Share on other sites More sharing options...
redarrow Posted January 6, 2008 Share Posted January 6, 2008 sorry do you mean match critrea that matches others critera like if the member both liked apples pull those two from the database......... Link to comment https://forums.phpfreaks.com/topic/84777-solved-help-with-db-query/#findComment-432074 Share on other sites More sharing options...
mediabob Posted January 6, 2008 Author Share Posted January 6, 2008 Actually what GingerRobot posted was perfect, that is exactly what I was trying to do but could not wrap my brain around it Thanks for the help, worked perfect Link to comment https://forums.phpfreaks.com/topic/84777-solved-help-with-db-query/#findComment-432116 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.