Jump to content

Recommended Posts

`user1_item1` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item2` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item3` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item4` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item5` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item5` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item7` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item6` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item9` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item10` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item11` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item12` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item1` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item2` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item3` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item4` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item5` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item5` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item7` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item6` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item9` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item10` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item11` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item12` LIKE '" . $db->escape($_POST['item_id']) . "'

 

If there anyway I can do like: `user%_item%`  LIKE '" . $db->escape($_POST['item_id']) . "'?

Link to comment
https://forums.phpfreaks.com/topic/191911-can-this-be-shortened/
Share on other sites

Having 24 columns named like that indicates a bad table design. So the answer is yes you can simplify that, by starting with a good table design.

 

And, no you cannot use wild-cards in column names. You must specify each column name individually.

Well, how would you do it? It's a trade logging system for a RPG. There's 2 players, each with 12 inventory spaces. Every item has to be logged so we can search by item ID. I don't want to have a string in a VARCHAR so I couldn't think of any other way.

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.