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 8458133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:59:44+00:00 2026-06-10T12:59:44+00:00

What I mean is, for example, if I search for something on an SQL

  • 0

What I mean is, for example, if I search for something on an SQL table, and it returns 0 / nothing, is that null or empty or does it result in an empty “”?

I’m getting back into php and trying to loop through a db like so:

Pseudo code:

while($row = mysqli_fetch_array($var here that has the query to the db and connection)){
      echo $row[//something pulled from table to be read back]
}

But let’s say that the search query didn’t return any results or that $row doesn’t equal to anything because for whatever reason, the value searched for in the db doesn’t exist,

How then can I check for the empty-ness of row?

if the searched for item doesn’t exist in the db, then $rows value becomes what exactly? null/empty/or empty string or something else?

depending on the value of row, do I test for [isset / !isset] or [empty / !empty] ? Or is the only way to test for empty $row to do a (pseudo) $x =mysqli_num_rows(var here) / if ($x == 0 ) //do something?

  • 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-10T12:59:46+00:00Added an answer on June 10, 2026 at 12:59 pm

    If mysqli_fetch_array did not return anything, then the return value is NULL

    The line while($row = mysqli_fetch_array is supposed to return the next available record in the record set, so if the query did not give any matching results, then the line echo $row['something'] does not get executed at all.

    If there are multiple fields you are fetching, say field1, field2 and supposing field2 doesn’t have a value, then what is returned for that field is what the default value for that field will be in MySQL (or whichever DB you are using). However the point to note is that $row will still have two keys defined correctly as $row['field1'] and $row['field2']

    If you want to check if $row['field2'] does have any value you can check it using empty($row['field2']).

    "", 0, NULL, FALSE, array() are all considered empty() so you should be able to safely determine if the field has any valid value in it using this function. However, if say 0 could be a valid value (for e.g. you are querying no_of_days a person was absent last month and some of them have full attendance), you will need to explicitly check the value in the field and cannot depend on empty().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For an example of what I mean, search on Google for Last.fm. The first
what does the colon mean in php in the following example. ::1 if($host ==
What does the smode of scipy.optimize 'Positive directional derivative for linesearch' mean? for example
What is the meaning of (char)0 . For example what does this mean? array[1]
Here's an example of what I mean: I have an array: array('type'=>'text', 'class'=>'input', 'name'=>'username',
concrete example http://img246.imageshack.us/img246/602/6x7gridsm.png By address I mean the location if you were counting left
For example in $(CC) $(CFLAGS) -c -o $@ $< what do they mean?
By dynamic data rating I mean a time-based recommendation system. One example use case
What do this and $(this) mean inside a widget method like create? For example,
Let me explain what I mean with that question: Lets say I have to

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.