Database search and display results

Hi everyone,

I’ve started dealing with Databases. I’m designer so I don’t have much idea on this.
I have created a Database or Dataset with a list of people, addresses, Telefon numbers, etc… The thing is that I need to create a search tool that goes to that database and shows the results in a table with all the fields. For example, I type Germany and I get a table with all the members living in Germany, with names, telephone numbers, etc… Actually something very simple… but not for me :slight_smile:

Here is the address of the web I need to re-design with the “old” search engine. Just look for FIND A STRINGER NEAR YOU section under the homepage photo.
http://www.ersa-stringers.com/

Thanks in advance for your help

Hi getsetmg,

Have you you checked out this Search code video? It could possibly help you, link to video: - YouTube

Link to forum article: https://www.wix.com/code/home/forum/questions-answers/search-a-database

If you are looking for a different type of search function, in this forum search for the words: filter dataset, filter table, search table

Happy coding!

Hey getsetmg,

First off, @Nayeli has great stuff available so take a look. Watch her video, but maybe eat first :wink:.

I was going to explain about databases, collections, datasets, binding, and so on, but there is a very nice video which does a great job of explaining the terminology and more importantly, how to use it. Take a look at Working with Datasets in 5 steps .

There are also a number of other very useful tutorials available the Video Tutorials page .

And - you can of course ask here in the forum if something isn’t clear or doesn’t work for you.

All the best,

Yisrael

Hi Nayeli,

it works!! thanks so much!!

And also thanks Yisrael for the nice tutorials!!

Hey getsetmg,

I told you Nayeli has some great stuff. Glad you got it working.

And for the tutorials, you can thank the tutorial team at Wix. They do a really great job.

Yisrael

Hi everyone,
I am creating a database with columns: Name, District and Blood Groups. Now I want to display the search results of the people of a particular district with a particular Blood Group. What should be the code? The ‘or’ code is not working. Please help!
Thank you in advance.

I have create a databse with this code, but when i type in the search textbox and click search button nothing is showing. please help

Please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor.

https://academic11.wixsite.com/oatc/certificates

Hi,

Your problem is that you have your table connected to a dataset, and you are trying to set the rows from a query at the same time. You should choose only one method. If you want to use the dataset, then you can set a filter on the dataset. If you prefer working directly with the collection using wix-data, then you should do a query and set the rows to the query results.

I would suggest reviewing the documentation on Database collections , and on connecting to a collection using Datasets .

You might also want to read the tutorial How to Use Code to Let Your Users Search a Collection which will guide you step by step to do exactly what you want.

Good luck,

Yisrael

Hi Yisrael
Thank you for your reply and help,

I couldn’t figure it out, could you please explain in detail. thanks

Line 12 … you have a capital “C”

Your database does not start with a capital letter.

Hi Nayeli,

Thanks for replying, i have changed (C) to small, but still not working

any help

Hi Mr Yisrael
I have a question for you
How do I make a search filter for similar data
Used onclick button
Example
I have customer data entered on a daily basis and I would like to inquire about the number of customer-specific records that were repeated by mobile number during
I would like to have a table only for customers with more than one record
Can you help
Thank you

@alkanani98 See the Content examples to see different ways to search and filter your data.

Create an input field, a button, a table to display result

import wixData from “wix-data”

export function button1_click(event) {
wixData.query(“collectionnamehere”)
.contains(“title”, $w(“#input1”).value)
.find()
.then(res => {
$w(“#table1”).rows = res.items;
});
}

$w.onReady(function () {
$w(“#table1”).columns = [{
“id”: “name”,
“dataPath”: “title”,
“label”: “Name”,
“type”: “string”,
}, {
“id”: “fname”,
“dataPath”: “fatherName”,
“label”: “Father Name”,
“type”: “string”,
}];
});