Basically I am building an auto Awards system for users of my forum. What it will do is check if they meet the criteria for the award IE Posts, Karma etc.... Allow the member to self issue if they meet this criteria..
One problem I am facing is I would like to query the MySQL database once and have multiple checks on each award to see if they already have it.. If not allow them to self issue the award by clicking a button.
Here is what I have so far
//Query Member Awards DB to check if we already have this Award
$query2 = $smcFunc['db_query']('', '
SELECT id_award, id_member
FROM {db_prefix}awards_members
WHERE id_member = {int:id_prof}',
array(
'id_prof' => $user_info['id'],
)
);
$info2 = $smcFunc['db_fetch_assoc']($query2);
echo $info2['id_award'];
if ($info2['id_award'] == '27')
echo 'exists';
My table looks like this
uniq_id id_award id_member date_received favorite
44 29 1 2011-11-02 1
31 21 1 2011-11-02 0
41 32 1 2011-11-02 0
43 27 1 2011-11-02 0
34 18 1 2011-11-02 0
35 38 1 2011-11-02 1
39 31 1 2011-11-02 0
40 30 1 2011-11-02 1
Now basically underneath I will have a bunch of Awards all with different ID's I want to be-able to say if exists do not display a button.. Now it would be fine if there was only one award to check but I need to check for a few awards.
I don't want to be making multiple queries using the where clause to see if this member already has this award.
Is there a simpler way of doing this so I only need one query and can check for multiple awards..
if ($info2['id_award'] == '1')
echo 'exists';
if ($info2['id_award'] == '2')
echo 'exists';
And so on
I am pretty puzzled at the best way todo this. Any help would be amazing.
EDIT:
Yeah basically its gonna look like this.. I will be using ajax to submit the data..
if ($info2['id_award'] != '27') && ($info['karma_good'] >= '100') {
echo '
<form id="karma_god" method="post">
<input type="hidden" id="recipient_to" name="recipient_to" value="' . $info['id_member'] . '" size="32" />
<input type="hidden" id="award" name="award" value="28" size="32" />
<input type="hidden" id="year" name="year" value="' . date('Y') . '" size="32" />
<input type="hidden" id="month" name="month" value="' . date('n') . '" size="32" />
<input type="hidden" id="day" name="day" value="' . date('d') . '" size="32" />
<span>You have above 100 Karma! A New Award Awaits. </span><button class="button"> <img src="http://www.uniquez-home.com/awards/28.gif" alt="" style="vertical-align:bottom;"> Karma God </button>
</form>';
And obviously for a few more awards 2 underneath this one..