Jump to content

Ganners

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by Ganners

  1. I am having trouble with a regular expression, the string is: http://example.com/example-page?&profession[]=Nurses&skill[]=Renal/Dialysis How my regular expression should work is a preg_replace which can grab either of these. At the moment I can grab both using: (&)(profession)(\[\])(=)(.+)(&) where 'profession' is a variable passed to the string in PHPm and could also be 'skill' etc. But this means my string has to end in a &! So what I need is something to say if the end & isn't there, it is the end of the string and replace what it has matched otherwise. So I though stuff like: (&)(profession)(\[\])(=)(.+)(&*) - *meaning 0 or more (&)(profession)(\[\])(=)(.+)(&|\z) - Match & or end of string might work, but they don't . I can work around by checking for the end & and sticking one on before the regex but that's cheating! Thanks for any help! Mark
  2. Wow thank you very much DavidAM, that worked a treat straight out with a copy paste! Saved me a lot of head bashing here.
  3. I have a table of data which has headings of: catID and AnswerID Each catID can have many answers, and those get filtered down and an array gets passed. So, at the moment I have this select statement: "SELECT catID FROM $mytable WHERE answerID IN (".implode(',', $answerIDArray).")"; This selects of course every catID which matches an item in the array. But if I have: catID AnswerID 6 64 6 72 6 77 7 64 7 73 7 81 I want to, for instace, if I pass an array containing 64 and 72, I want it to return only catID = 6, and if I did an array containing only 64 i'd want it to return 6 and 7. Does this make any sense? I'm terrible at explaining things. Is this something I could just use php for? Something I think I could use would be to keep my currect select statement, then print out any catID which which is repeated the count of the array I passed in the first place, but I'm not sure how efficient or logical that is. Thanks for any help!
  4. Ah okay I understand this, I'll be using a many to many. Thanks for your help thehippy!
  5. I am working on a site for a client where there are a list of products. He wants the user to be able to have drop down boxes to select parent questions, then another box will appear with child questions to filter through the database of products. What is the best way of doing this? I was thinking about: -Having a table for products -Having a table for questions -Having a field in the products table called "QuestionIDs" and it containing something like "1, 5, 9, 21, 15" (so id's seperated by a comma to the corresponding questions which describe this). Is this a good way? Is there a better way? Thanks for your help
×
×
  • 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.