oskare100 Posted January 3, 2007 Share Posted January 3, 2007 Hello,I have a table where I add the items I have. When I receive a new order I get the title of the item the new order contains, and I assign that title the variable $title in the script that is supposed to match/identify the new order with an item in my database.Here is the database structure;[CODE]CREATE TABLE `items` ( `item_id` int(11) NOT NULL auto_increment, `item_name` varchar(100) NOT NULL default '', `price` varchar(30) NOT NULL default '', `identify_pos` varchar(50) NOT NULL default '', `identify_pos2` varchar(50) NOT NULL default '', `identify_neg` varchar(50) NOT NULL default '', `identify_neg2` varchar(50) NOT NULL default '', `file_name` varchar(100) NOT NULL default '', `file_pack` varchar(30) NOT NULL default '', PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;[/CODE]So I need the script to see if the title matches any of the items in my database. As soon as the script finds a row where the $title contains identify_pos and identify_pos2 but not identify_neg or identify_neg2 then it should get the item_id of that item and continue. If it can't find any match, then do something else..Also, identify_pos, identify_pos2, identify_neg and identify_neg2 can be empty but I hope that doesn't make it more difficult.. If it does it is OK if all must contain something. Maybe I've forgotten to mention something important here but I'mm monitor this thread so just reply.. Is it possible to do that with PHP and if, how can I do it? I'm not that good at PHP so I can't figure out how to do that myself.. Thanks in advance,/Oskar R Quote Link to comment Share on other sites More sharing options...
printf Posted January 3, 2007 Share Posted January 3, 2007 Does the title have to be in both (identify_pos, identify_pos2) or can it be in in just one of those. If it need to be in both, then...[code]SELECT item_id FROM items WHERE identify_pos = '" . $title . "' AND identify_pos2 = '" . $title . "'[/code]OR, if it can be in one or the other[code]SELECT item_id FROM items WHERE identify_pos = '" . $title . "' OR identify_pos2 = '" . $title . "'[/code]In other words..., the query can be done any way you want, but how it's done will be based on exactly how you want the restriction to work. But then again, if you already have a order, then why don't you have them [b]item_id[/b] with the order, seeing it is the [b]key[/b] to the items table!printf Quote Link to comment Share on other sites More sharing options...
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.