No results to display

Hello Wix geniuses,
I’m in need of your help.
I’ve built a site with a dataset (Tenant_Blacklist) with a function that allows users to search the dataset for the full name of a tenant in the dataset. That works fine (or at least it did until I tried this next bit).
I’ve tried to add a “no results found” message when the name searched doesn’t match any results in the dataset.
First I tried to add it as a text box that would only display if total count = 0. Couldn’t get that to work so I scrapped it and tried to display a default result (a line within the dataset that reads “no results found”) within the table if the results of the search =0.
It still won’t display the “no results found” and now it won’t display the results when there are results to display.
If anyone could help me it would be very much appreciated.
I’ll paste the page code below:

import wixData from “wix-data”;

// For full API documentation, including code examples, visit Velo API Reference - Wix.com

//TODO: write your page related code here…

export function searchbutton_click(event) {
//Add your code for this event here:
// Runs a query on the “tenant” collection
wixData.query(“Tenant_Blacklist”)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.contains(“tenantFullName”, $w(“#input7”).value)
.find() // Run the query
.then
(res1 => {
if (res1.items.length ===0) {
wixData.query(“Tenant_Blacklist”)
.eq(‘title’, “No Reviews Found”)
.find(res2 => {

// Set the table data to be the results of the query
$w(“#table1”).rows = res2.items;
});
}})
}
$w.onReady( function () {
$w(“#table1”).columns = [
{
“id”: “col1”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “Country”,
“label”: “Country”, // The column header
“width”: 150, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col2”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “tenantFullName”,
“label”: “Tenant Full Name”, // The column header
“width”: 150, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col3”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “DOB”,
“label”: “Date of Birth”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col4”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “scoreOutOf10”,
“label”: “Score Out Of 10”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},

  { 

“id”: “col5”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “rentalAddress”,
“label”: “Rented Address”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col6”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “landlordPropertyManagerName”,
“label”: “Property Manager’s Name”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col7”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “landlordPropertyManagerPhoneNumber”,
“label”: “Property Manager Phone”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col8”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “reasonsForReviewScore”,
“label”: “Reviewer Notes”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col9”,
“dataPath”: “photos”,
“label”: “photos”,
“visible”: true ,
“type”: “image”,
“linkPath”: “link-field-or-property”
},

// more column objects here if necessary
// …
// …

]}); 

Thanks in advance,
Leigh

Why do you have 2 queries?
Why don’t you populate the table if there’re results?

I want the table to populate if there are results, and i want the table to populate a specific line that reads “no results found” if there are no results.

It doesn’t answer my questions.
In your code, you have no code for populating the table if there are results. So obviously it won’t get populated.
In you’re code you’re running 2 queries, what’s the purpose of the second one?

@jonatandor35 It’s an example i found online.
This is what i was running prior to trying to add the “no results found” message.

export function searchbutton_click(event) {
wixData.query(“Tenant_Blacklist”)
.contains(“tenantFullName”, $w(“#input7”).value)
.find()
.then
(res => {
$w(“#table1”).rows = res.items;
});
// }})
}
$w.onReady( function () {
$w(“#table1”).columns = [

This populates the table with results (as needed).
What i need is a way to display a message that says “no results found” when there are no results to populate. How do i make that happen?

@badtennants use the code from your last message (not the first one you posted).
in the then() block put:

//code code .....
.then((res) => {
    if(res.items.length > 0){
        $w("#table1").rows = res.items;
        $w("#table1").expand();
        $w("#text1").collapse();//this is a texbox for "No results found" message
    } else {
        $w("#table1").collapse();
        $w("#text1").expand();
    }
})

This works! Thanks J.D.