0

I'm converting all MySQL to MySQLi pages. I need to select all rows where a column starts with a letter.

On MySql If I want all rows starting with P, I used to add % to P, so I'll search all entries LIKE P%, but it's not working on MySQLi

If $type = P%

$result = $mysqli->query("SELECT * FROM my_table WHERE column LIKE $type");

I get no results.

I appreciate any help you can provide.

William Orellana
  • 147
  • 1
  • 2
  • 7

1 Answers1

1

Try putting quotes around the variable in the query so that it looks like this :

$result = $mysqli->query("SELECT * FROM my_table WHERE column LIKE '$type'");

This will probably solve the problem.

Nijraj Gelani
  • 1,446
  • 18
  • 29