I use this query to select books from my database to a website page
$query = "SELECT *
FROM `bibliografie`
WHERE keywords like '%$tema%' [...];
$result = mysqli_query($db, $query) [...];
and in the single webpage I have
<?php
$tema = "Luther";
include "$root/commune-mysql_bibliography.php";
?>
In some cases I have a webpage related not only to one theme (‘tema’: matter, topic), therefore it would be useful if I could set several keywords in the query. I.g. in a webpage about Martin Luther I’d like to have as keywords Protestantism, but also Germany, or XVI century, of History of Church. So I’d like to have books of all these keywords.
If would be possible?
How could I do?
Thank you!
EDIT
To be more clear: how could I set $tema = "Luther,Germany,XVI century"
// If a search term was provided, use a full-text search on the 'content' field.
// Before this can work, you'll need to make sure your content column is indexed for full-text searching.
// You can do this with the following SQL command:
// Example:
// ALTER TABLE cms ADD FULLTEXT(content);
if($searchTerm !== null) {
$sql = "SELECT * FROM cms WHERE MATCH(content) AGAINST(:searchTerm IN NATURAL LANGUAGE MODE) LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':searchTerm', $searchTerm);
// If a heading was provided, search for exact matches on the 'heading' field.
}
this is using PDO. I’m not too familiar with mysqli. Where content is a database table column name.
Thank you, but meanwhile I found myself this very simple (php and not mysql) solution:
in the common file
"SELECT *
FROM `bibliografie`
WHERE keywords like '%$tema%' $altritemi
in the single webpage:
<?php
$tema = "Luther";
$altritemi = "or keywords like '%Germany%' or keywords like '%XVI century%'";
include "$root/commune-mysql_bibliography.php";
?>