steve m Posted April 7, 2006 Share Posted April 7, 2006 I was wondering how to pass the "like" command in a URL. Is this possible? For example: /equip_list.php?item_code=SONIC&sub_cat[b]like[/b]app%I tried to do that and it didn't come up with the right results. Quote Link to comment https://forums.phpfreaks.com/topic/6812-wanting-to-know-if-you-can-pass-like-in-a-url/ Share on other sites More sharing options...
kenrbnsn Posted April 7, 2006 Share Posted April 7, 2006 How did you try to do it and what results did you get/expect. You can pass what ever you like in the URL. How you use it is up to you.Ken Quote Link to comment https://forums.phpfreaks.com/topic/6812-wanting-to-know-if-you-can-pass-like-in-a-url/#findComment-24771 Share on other sites More sharing options...
steve m Posted April 7, 2006 Author Share Posted April 7, 2006 I tried this: [a href=\"http://www.rcubed.com/equip_list.php?item_code=SONIC&sub_catlikeapp%\" target=\"_blank\"]http://www.rcubed.com/equip_list.php?item_...sub_catlikeapp%[/a] and it came up with about 181 results, where it should only come up with about 30 - 40 results. Quote Link to comment https://forums.phpfreaks.com/topic/6812-wanting-to-know-if-you-can-pass-like-in-a-url/#findComment-24784 Share on other sites More sharing options...
Zane Posted April 7, 2006 Share Posted April 7, 2006 how are you sending the Search to the URL first of alland secondly what code are you using to Search from the urlhelps more if you provide some codemy guess is that when you are searching from what's shown in the URLyou're assuming subcat is always equal to it's valueit that's the problem you should have it look at the value.....(likeapp%)...first and thentell it to say.....WHERE subcat LIKE 'app%'instead ofWHERE subcat = 'likeapp%'LIKE works just as good as equals...especially when you're going to be using wildcards Quote Link to comment https://forums.phpfreaks.com/topic/6812-wanting-to-know-if-you-can-pass-like-in-a-url/#findComment-24785 Share on other sites More sharing options...
steve m Posted April 7, 2006 Author Share Posted April 7, 2006 here is the url that I'm trying to pass.[a href=\"http://www.rcubed.com/equip_list.php?item_code=SONIC&sub_catlikeapp%\" target=\"_blank\"]http://www.rcubed.com/equip_list.php?item_...sub_catlikeapp%[/a]for some reason it doesn't like that. It's selecting more records than it should. How can you use a wildcard in a url? Quote Link to comment https://forums.phpfreaks.com/topic/6812-wanting-to-know-if-you-can-pass-like-in-a-url/#findComment-24791 Share on other sites More sharing options...
Zane Posted April 7, 2006 Share Posted April 7, 2006 somewhere in your equip_list.php fileyou are telling it to do something like this I assume[code]$sql = "SELECT * FROM sometable WHERE subcat = '" . $_GET['subcat'] . "'";[/code]you need to have it do this instead[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$sql = "SELECT * FROM sometable WHERE subcat [b]LIKE [/b]'" . $_GET['subcat'] . "'";[/quote]so just change you link to go to[a href=\"http://www.rcubed.com/equip_list.php?item_code=SONIC&sub_cat=app%\" target=\"_blank\"]http://www.rcubed.com/equip_list.php?item_...IC&sub_cat=app%[/a]after you have changed your PHP script Quote Link to comment https://forums.phpfreaks.com/topic/6812-wanting-to-know-if-you-can-pass-like-in-a-url/#findComment-24795 Share on other sites More sharing options...
steve m Posted April 7, 2006 Author Share Posted April 7, 2006 Yeah, it's probably the problem. Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/6812-wanting-to-know-if-you-can-pass-like-in-a-url/#findComment-24877 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.