Add similar items to the search results

In the end I managed to solve the problem of putting together the search data with the respective link and the other (visit here to see the result → hard-questions.com) but now I have a new problem: in fact when I go to search for example “how to create a google account” I would only see the article “how to create a google account” and not the others that contain the words like: how, create, a, account, google … How could I do to show also similar items? I leave you link of the code: https://pastebin.com/3J5R0GZq

You must split each keyword per space,so it will retrieve data that containing each keyword.

Also you already defined the result in your code
<?php if ($row->Name == "Come creare un account google") { $row->Name = '<a href="https://hard-questions.com/articoli/account-google-tutorial.html">Come creare un account google</a>'; } elseif ($row->Name == "Come formattare un dispositivo android") { $row->Name = '<a href="https://hard-questions.com/articoli/formattare-un-dispositivo-android.html">Come formattare un dispositivo</a>'; } ?>
So it will only show one result that already defined in your code

3 Likes

what should I do to recover data containing each keyword?

That is the result of the link, if I remove that then I will not have the results linked

Itu should be splitted for each keyword then using foreach loop to do the rest

1 Like

Would it work if it used the foreach loop and I didn’t delete the conditions for the links? What should the cycle look like?

If you’re using foreach loop then you should remove those conditions,you should create new column in your database to store the urls so it can be executed automatically by the foreach loop.
I suggest you to ask in a programmer forum,i recommend stackoverflow.

could it be fine this way?

<a href=<?row->Link?>><?row->Name?>

I mean instead of the if to make the links work

It can be,but make sure to use the right separation

It sounds like what you want is full text search. I believe MySQL can do this, if you create a table with a FULLTEXT index on the database column you want to search for. But I don’t know whether free hosting supports this.

But if you want to have really powerful search capabilities, you’ll probably need a database which is optimized for it. Software like Elasticsearch or a service like Algolia is built for this purpose.

No, it doesn’t work, show this error ** Parse error **: syntax error, unexpected ‘$ row’ (T_VARIABLE) in ** / home / vol6_5 / epizy.com / epiz_24872058 / htdocs / provb.php ** on line * * 40 **
I guess I’ll have to do it all over again with full text :disappointed_relieved:

it is <a href='<?php echo row->link;?>'> <?php echo row->name; ?></a>

Ho incollato la seguente riga: <?php echo row->name; ?>

Ho ottenuto Parse error : syntax error, unexpected ‘->’ (T_OBJECT_OPERATOR), expecting ‘,’ or ‘;’ in /home/vol6_5/epizy.com/epiz_24872058/htdocs/provb.php on line 40

<a href='<?php echo $row->link;?>'> <?php echo $row->name; ?></a>
My brain is hanging.

But I don’t get the link, this is the result https://hard-questions.com/provb
This situation is very difficult

Now it seems to work, finally

I would just miss the thing to show more similar results
To do this I would perhaps need a cycle but the condition would be practically difficult to set

I would like to thank you because you are helping me a lot :grin:

1 Like

I think i need to modify the above part of the code (from first “if” to end of the second “if”)(CodePile | Easily Share Piles of Code) somehow, because I’m noticing that the Name variable can only take one result

yeah because it using the wrong separation

1 Like