Kryptix Posted February 12, 2010 Share Posted February 12, 2010 `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 More sharing options...
PFMaBiSmAd Posted February 12, 2010 Share Posted February 12, 2010 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. Link to comment https://forums.phpfreaks.com/topic/191911-can-this-be-shortened/#findComment-1011541 Share on other sites More sharing options...
Kryptix Posted February 12, 2010 Author Share Posted February 12, 2010 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. Link to comment https://forums.phpfreaks.com/topic/191911-can-this-be-shortened/#findComment-1011542 Share on other sites More sharing options...
fenway Posted February 16, 2010 Share Posted February 16, 2010 Usual many-to-many relation table applies here. Link to comment https://forums.phpfreaks.com/topic/191911-can-this-be-shortened/#findComment-1013136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.