MongoDB/PHP: search for string with query [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
EDIT: I solved it. Just need to use "MongoDB\BSON\Regex".
I'm storing books as documents in MongoDB, with the individual pages stored as strings in an array. I'm trying to implement a search page that can take a string and return all documents that contain it. Can this be done directly with a MongoDB query called using PHP (i.e searching for a substring within the string arrays)?
I'm using MongoDB\Driver ( http://php.net/manual/en/book.mongodb.php ) because it was the only option that worked on my machine, and I couldn't find detailed documentation or tutorials for this particular driver. Can anyone help?

Something like
db.table.find({"bookTextField": /.*(the string).*/})
EDIT: Of course, replace table by the table name and bookTextField by the field of the table containing the text

Related

How to display data from an html form in an html table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Please forgive me if this has been asked and answered before, but I couldn't find it in the search.
As stated in the title, I have a form built in HTML. I need the user inputted data to be displayed in an HTML table. I know the easiest way to accomplish this is probably to do so using SQL to store and then retrieve the data and PHP to output it in the table itself. For the life of me I cannot get this to actually work. Google is absolutely my friend but literally nothing I've tried actually works. Examples would be wonderful and I seriously appreciate the help! Thanks!
This link could help you: https://stackoverflow.com/a/15251402/4149985
Basically, you need a web server, either locally or via a hosting provider with access to a database.
Your database needs to have a table, which contains records.
You need to use PHP to connect to the database, retrieve the records and then output them as a HTML table.

How can I search for a specific word inside all my blade views in Laravel 5.5 or else [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to know how can I show pages that contain a specific word written by random user in input text, because some contents are static.
P.S : If what I'm talking about is deprecated, can you propose to me a best solution for doing such functionality?
The best option is to keep your data in database. It will allow you to search and display content dynamically. Also in case you have some static pages, you can put them in database just for searching purposes if it's solution in your case.

Are there alternatives to using a MySQL database for simple tasks like this? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Suppose I want a webpage containing only a tick box. I wanted it to be possible for anyone to change the value of the tick box, and then the value to update for anyone checking the page, would I have to use a MySQL database? Or is there a better way to do it?
You want a really simple thing. Of course you can use a database like MySQL for it, but it is seriously not needed in any way. You just have one value, so you could have a text file with that value and it would work too. It depends on what data you want to store.
A database is good because it offers you for example things like the query.

How can I Print a result on webpage using php getting from MySql database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a school website, I have uploaded the students examination result to the database but now I want to make a search bar by which can the student search their result by typing their roll number.
please someone give me the code. please
#wajahat-aftab - you can always find a great tutorial to do this. Here are few of the links
https://www.youtube.com/watch?v=N_S7_wg87GU
http://html.net/tutorials/php/
http://www.htmlgoodies.com/beyond/php/article.php/3472391
Basically you need to get the data, manipulate it and send it to the HTML page. Once you get the data in HTML you can present it any kind of look-n-feel as per your needs.
You can not expect exact answers for such questions - so I suggest you to be more specific with QUESTION and make sure that you also share the source code that you tried so far.

Check spelling before making a query [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing a small program where I want to extract user input strings from MySQL database. But I am not looking for exact matching strings. For example
If user types amazon then it should extract amazon from the database. But if user types amazonn or amazo or amozon it should still retrive amazon because it is the nearest word to the misspelled word.
This is something similar to google suggestions while searching. Is there anyway to define a function like this in PHP? Do i have to import dictionary and compare with it?
You could use strpos() in two ways
How do I check if a string contains a specific word in PHP?
Search for the DB string in the string that the user inputted.
And the other way around:
Search for the string that the user inputted in the DB string.
The problem with this is that you only cover differences at the outside of the string
such as amazo or amazonn but not amozon
Or you could use levenshtein() and similar_text() as stated in the comments.
Good example code with suggestions:
https://codereview.stackexchange.com/questions/27173/php-spell-checker-with-suggestions-for-misspelled-words
That should be covered in an entirely different way...
I think you want both checks but everything is going to be difficult without a dicitonary so I suggest importing one ;)

Categories