Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:23:50+00:00 2026-06-12T00:23:50+00:00

The following code shows an array of records in the $rows array from the

  • 0

The following code shows an array of records in the $rows array from the MySQL query. I have added also an if statement to check if $rows turns up empty, but it is not working.

$rows = array();

$result1 = mysql_query("SELECT * FROM TestPhase where Pid<10", $db) or die("cannot select");
while($row = mysql_fetch_array($result1)) {
  $rows []= array(
    'id' => $row['id'],
    'parent' => $row['parent'],
    'name' => $row['name'],
  );

}


if($rows == ""){
    echo "No Data";

    }

This if statement is not working. How do I check if the array returns empty and echo “No Data”.

How would I check to see if the array is empty in javascript? I have placed the $rows array in a var treeData.

if (treeData) is empty{
$("button").hide();
     }

How do I check if treeData is empty to hide the button.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:23:51+00:00Added an answer on June 12, 2026 at 12:23 am

    PHP
    Simply use empty(), i.e.

    if(empty($rows)){
        echo 'No Data';
    }
    

    Alternatively you could also use count(), i.e.

    if(count($rows) < 1){ // or if(count($rows) === 0)
        echo 'No Data';
    }
    

    JavaScript
    You can use the length property

    if(treeData.length == 0){
        $("button").hide();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code shows what I currently have. It is an adapter for circular
Currently, the following code shows a blank line if Address2 (which comes from the
The following code with alternating background I have shows up fine in Chrome and
In the following code, the first log statement shows a decimal as expected, but
I have the following code and when i try to get a value from
I have the following code: Array.class_eval do def abs_sort new_array = self self.each do
I have an array which is generated from an XML file and it shows
The following code shows a multi-dimensional array, and a function that loops through the
I have the following code where I have an array. I add a large
I have the following code: `$attachment = array( 'message' => test, 'text' => 'Download',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.