Schlo_50 Posted March 3, 2008 Share Posted March 3, 2008 Hey all, I have an option select box which contains values, 20000, 30000, 50000 and 80000 representing yearly wages. <select name="select" class="form"> <option value="20000">Under £20k</option> <option value="30000">Under £30k</option> <option value="50000">Under £50k</option> <option value="80000">Under £80k</option> </select> When for example a user selects Under £20k I need my preg_match function to find and match all values less than '20000'. And so on and so forth for the larger values. How can i do this using: $subjectc = "$salary"; $wage = "/".$_POST['salary']."/i"; if (preg_match($wage, $subjectc){ Thanks for any help! Quote Link to comment Share on other sites More sharing options...
trq Posted March 3, 2008 Share Posted March 3, 2008 Regular expressions are used to find patterns in strings, I'm not sure how this relates to your problem. What does $subjectc contain? Quote Link to comment Share on other sites More sharing options...
svivian Posted March 3, 2008 Share Posted March 3, 2008 Yeah no need for regular expressions at all. If you're just posting that form you'd need something like: $salary = $_POST['select']; // 'select' is the name you gave in the HTML if ( $salary == 20000 ) { // find stuff under 20k } else if ( $salary == 30000 ) { // find stuff under 30k } ...etc etc Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted March 3, 2008 Author Share Posted March 3, 2008 Cheers guys Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted March 3, 2008 Author Share Posted March 3, 2008 Would this work? if ($money == "20000"){ $subjectc = "20000"; }else{ if ($money == "30000"){ $subjectc = "30000"; }else{ if ($money == "50000"){ $subjectc = "50000"; }else{ if ($money == "80000"){ $subjectc = "80000"; } if (preg_match($jobtitle, $subject) && (preg_match($location, $subjectb) && ($salary == $subjectc))){ print_r ("$JOB_TITLE - $county<br />"); } Quote Link to comment Share on other sites More sharing options...
AV1611 Posted March 3, 2008 Share Posted March 3, 2008 it's salary <= '20000' if you do salary == '20000' it won't work unless you have a dropdown rather than a text entry. You prolly are using a dropdown, but I just thought I'd mention that cause you said: // find stuff under 20k which is won't, it will only find exact match. Sorry for splitting hairs 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.