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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:20:13+00:00 2026-05-26T11:20:13+00:00

I wrote a php search for a table in mysqli and it works fine

  • 0

I wrote a php search for a table in mysqli and it works fine but i want to show the correct message to user if no result were found.

here is my current code:

$search_string=$_GET["design"];

$connect= mysqli_connect("mysql.myhost.com","abc","123456","mydb_db");
$query="select * from product where product_design like '%$search_string%'";
$rows= @mysqli_query($connect,$query) or die("Error: ".mysqli_error($connect));
if ($rows!=null)//I put this if to check if there is any result or not but its not working
{

while(($record=mysqli_fetch_row($rows))!=null)
{
    .
            .//i have working code for showing the result here
            .
}   
mysqli_close($connect);
}
else{
echo"no result found";
}

could you please help me what is wrong , even when i search for something which is not exist in the db still the program not displaying “no result found”

Thank you

  • 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-05-26T11:20:14+00:00Added an answer on May 26, 2026 at 11:20 am

    What you need is mysqli_num_rows specifically the mysqli_result::num_rows bit. This adds a num_rows property to mysqli result sets. This means you can do

    $rowCount = $rows->num_rows

    There’s also a non-OO equivalent …

    $rowCount = mysqli_num_rows($rows);

    (The difference is purely one of coding style)

    Use one of these to determine how many records are returned and output the appropriate messages.

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

Sidebar

Related Questions

I wrote a PHP code like this $site=http://www.google.com; $content = file_get_content($site); echo $content; But
I wrote a PHP CUrl Class, if i execute Methods which should return the
I just wrote a PHP login script, and what I'm trying to accomplish is
I wrote a small PHP application several months ago that uses the WordPress XMLRPC
I wrote a small PHP application that I'd like to distribute. I'm looking for
First of all, I wrote a simple php page, that picks up some variables
I have a php function I wrote that will take a text file and
I wrote a web service API which services REST requests in php. It didn't
Being a pretty experienced PHP developer, and having a fair knowledge of C (Wrote
I am trying to see what is wrong with a php script a wrote.

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.