boionfire81 Posted July 11, 2016 Posted July 11, 2016 Ok, I'm using mccodes so there are a lot of limitations and hurdles. But how would I be able to make this query? Quote
boionfire81 Posted July 11, 2016 Author Posted July 11, 2016 the item types table. I have about 22 and only half of them are "legal" so the others get sold elsewherez. lol Quote
TheMasterGeneral Posted July 12, 2016 Posted July 12, 2016 One moment... $FieldToTest=$Array; //The array to test $WhatToTestFor=array('foo','bar','etc'); //What to test for if (in_array($FieldToTest,$WhatToTestFor)) { //success } Quote
boionfire81 Posted July 12, 2016 Author Posted July 12, 2016 ok so, if $qys is the db fetch or query? would be equal to FieldToTest and foo, bar, etc just replace with the id #'s? Quote
TheMasterGeneral Posted July 12, 2016 Posted July 12, 2016 If I understood correctly, yes. Just for confirmation: $ArrayToTest=$db->fetch_array($query); $IDs=('id1','id2','etc'); if (in_array($ArrayToTest,$IDs)) { //yeah } Quote
boionfire81 Posted July 12, 2016 Author Posted July 12, 2016 $IDs=('18','16','15','13','3','4','2'); $gk=$db->query("SELECT * FROM itemtypes"); $itype=$db->fetch_row($query); while (in_array($itype,$IDs)) { All I'm getting there Parse error: syntax error, unexpected ',' in That is the $ID line. I tried moving the line above the other lines and the error line number just changed with it. Quote
TheMasterGeneral Posted July 12, 2016 Posted July 12, 2016 Oh, my apologies. Made a sleepy coder derp. Replace the $IDs line with: $IDs=array(18,16,15,13,3,4,2); Quote
NonStopCoding Posted July 13, 2016 Posted July 13, 2016 $items = array_unique(array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22)); $itemtypes = $db->query("SELECT `itmtypeid`,`itmtypename` FROM `itemtypes` WHERE `itmtypeid` IN(".implode(',',$items).")"); if($db->num_rows($itemtypes)) { // use the num rows to check if its real while($itm = $db->fetch_row($itemtypes)) { // success run whatever it is you are trying. } } else { // failed } just change the ids to whatever you want to show or you can alter the query and make it say NOT IN and then have your ids you wish to block. Quote
Magictallguy Posted July 15, 2016 Posted July 15, 2016 Why aren't you going via itemtype? Isn't that generally what it's for; easier differentiation? 1 Quote
boionfire81 Posted July 15, 2016 Author Posted July 15, 2016 Why aren't you going via itemtype? Isn't that generally what it's for; easier differentiation? I am talking about itemtype. But I do not want to use ALL the item types. Quote
Magictallguy Posted July 15, 2016 Posted July 15, 2016 SELECT `itmid`, `itmname` FROM `items` WHERE `itmtype` IN(1, 2, 3) Alter the IN clause to whitelist the item type IDs you want to use there Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.