I am having issues with the following code of mysql when using the "not like" mysql command. My snippet looks like this

$name = something

$sql = "Select * from table1 where table1.field1 not like ' $name ' ";

What it should look like in phpmyadmin is

Select * from table1 where table1.field1 not like %something%

But I am not sure on how to put in the percentage signs. I have tried this with no success

$sql = "Select * from table1 where table1.field1 not like /%' $name'/%  ";

Is there any method for putting in the percentage wildcard??

Thanks in advance
Where Are My Sports

Recommended Answers

All 2 Replies

$sql = "Select * from table1 where table1.field1 not like '%$name%' ";

Use it this way

$sql = "Select * from table1 where table1.field1 not like '%". $name%."' ";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.