[英]mySQL Like $query - Using a GET variable as the %LIKE% value
I am using a mySQL query which currently looks for just one value in this as such; 我正在使用一个mySQL查询,该查询目前仅在其中查找一个值。
"SELECT * FROM $usertable WHERE tabID LIKE '%spotlight%'";
this sits on index.php and this works great, however I would like the search value "spotlight" not to be hard coded, but so it is achieved from the URL 它位于index.php上,效果很好,但是我希望搜索值“ spotlight”不要硬编码,但是可以通过URL实现
So when I go to 所以当我去
index.php?type=spotlight
ill get spotlights. 生病了。 and when I go to
当我去
index.php?type=lamps
I will get lamps 我会拿灯
I have player around with this and at I am sure its something like this which I have been trying to make work... 我周围有玩家 ,我确信我一直在努力工作,就像这样……
$product_type = $_GET['type'];
//* and then lower down where the query sits *\\
"SELECT * FROM $usertable WHERE tabID LIKE '%$product_type%'";
but it really didn't like this and eded up showing all values for the $usertable 但是它确实不喜欢这样,并编辑了$ usertable的所有值
Any help would be greatly appreciated 任何帮助将不胜感激
Regards 问候
Henry 亨利
"SELECT * FROM $usertable WHERE tabID LIKE '$type'";
尽管更改了搜索条件,但必须删除%,但必须完全包含该技巧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.