Jump to content

Recommended Posts

using the count(itemid) as itemcnt lets you pull it as a variable from your mysql_fetch_assoc

 

$query = mysql_query("SELECT count(itemid) as itemcnt, `date` FROM table_name GROUP BY `date`");

$row = mysql_fetch_assoc($query);

 

print $row['itemcnt'];

 

will give you the count.

Link to comment
https://forums.phpfreaks.com/topic/146882-php-check-for-values/#findComment-771177
Share on other sites

You posted no relevant code or information. You asked that a member deposited 5 items, I am taking it that you have a table of items which is linked to a member by a member id (I need to amend this). The table should have a primary key of "id" (I used itemid to hopefully paint the picture/give you the idea). The as will assign it to the returned array from mysql_fetch_assoc function as $fetchedData['itemcnt'].

 

To do this by member:

SELECT count(itemid) as itemcnt, `date` FROM table_name WHERE memberid = '2' GROUP BY `date`

 

Or for all members:

SELECT count(itemid) as itemcnt, `date`, memberid FROM table_name GROUP BY `date`, memberid

 

But yea, provide us with code you have tried or current code and you will get far better and much more detailed help.

 

Link to comment
https://forums.phpfreaks.com/topic/146882-php-check-for-values/#findComment-771184
Share on other sites

I work with name not id

 

Well replace the itemid with name. Although this is a poor design for a DB (not 3NF form) that should work. Like I said, I was just trying to paint a picture, you not providing us with code etc is like hte blind leading the blind.  You asked howto, I explained it. You never said, "Here is how my DB is setup here is some code I tried can anyone help me modify the code to work."

 

It was more or less, "Can this be done if so how".

Link to comment
https://forums.phpfreaks.com/topic/146882-php-check-for-values/#findComment-771191
Share on other sites

Alright let my try again.

 

What my whole script does is It logs in to a game using curl and checks the action log, if an item was awarded or deposited by a member it logs in my table called actionlog

 

which is set up like this

 

id (unique id for every entry)

name (name of player involved)

action (deposited or awarded)

item (name of the item example Holy Potion)

itemid (the unique id for each item)

date (date which it was deposited or awarded)

awarder (if item was awarded, by who)

apsvalue (the amount of points given to member for depositing that item)

 

Now what I want to do is on a different page im starting with a query that checks everything in actionlog where name = session username and what I want to do is check if the user has deposited a Holy Potion and a Arcane Potion and a Shadow Potion and a Fire potion AND a kinetic potion all on the same day, and if so then something, if not then nothing.

 

Hope Im a bit more clear.

Link to comment
https://forums.phpfreaks.com/topic/146882-php-check-for-values/#findComment-771197
Share on other sites

it mean thet member have 5 record with item in ('holy potion', 'arcane potion', 'fire potion', 'shadow potion', 'kinetic potion') 5 of 5

 

if member can have more then one same items in same day (2 holy potion in one day) change to

 

'HAVING COUNT(DISTINCT item) = 5'

Link to comment
https://forums.phpfreaks.com/topic/146882-php-check-for-values/#findComment-771221
Share on other sites

okay and by the way it doesnt work,

 

Like i tested for a bunch of things and it worked

 

I added a code to tell me if it matched or not

 

if($selaps >0)

{

echo 'yes';

}else{

echo 'no';

}

 

And What i did is I inserted values in database to test

 

If they have 4 potion is says no if it wasnt on same day it says no, if they have holy arcane fire shadow and kinetic it says yes

 

HOWEVER

 

if he has holy, holy, shadow, arcane and kinetic it says yes but theres no fire.

Link to comment
https://forums.phpfreaks.com/topic/146882-php-check-for-values/#findComment-771230
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.