Workaround on Numrows coming up with 1 when 0 results

Discussion in 'Customizations' started by performancecentral, Jul 19, 2013.

  1. Hey all,
    I have noticed (and found this in previous topics before) that if you run $numrows, if you end up doing a search and get 0 results you will get a numrows value of 1

    Is there any way around this so far?

    Thanks in advance,
  2. Hey all,
    I'm just wondering if I may have found a work around:

    In looking at the /public_html/includes/classes/kernel/Listings.php file I found the following code:

    //get the number of listings
    $resultSet = $db->query($listingSQL);
    $numrows = $resultSet->num_rows();
    $resultSet->freeResult();
    if ($numrows == 0)
    {
    $numrows = 1;
    }


    I changed it around to the following and it worked fine from now on

    //get the number of listings
    $resultSet = $db->query($listingSQL);
    $numrows = $resultSet->num_rows();
    $resultSet->freeResult();
    if ($numrows == 0)
    {
    $numrows = 0;
    }
  3. Mike-N-Tosh Owner

    Where exactly is this an issue? What exactly do you mean by, "if you run $numrows"??? What are you trying to do?

    As far as I know, the only time the variable, $numrows is used is for pagination which takes this into account. Bare in mind that in any type of programming, indexing starts with 0 as opposed to human counting which starts with 1. As far as I now and can see for the little amount of time I spent on this, the variable $numrows isn't even assigned to the template.

    So again, I ask, where exactly is this an issue?
  4. Hey Mate,
    Thanks for your help.

    The issue comes about from displaying how many results are displayed from a search result.

    Without changing that code in the Listings.php file, if there is 1 result it would display $numrows as 1 but if there is no results then $numrows still appears as 1.

    I found that code on line 495. It did fix the issue that I had though.
    With 1 result found:
    http://www.performancecentral.com.a...=Queensland&minprice=&maxprice=&Submit=Search

    With 0 Results found (this is after changing the code above)
    http://www.performancecentral.com.a...h Australia&minprice=&maxprice=&Submit=Search

    I remember a few other members mentioning they had the same issue when displaying 0 results.

Share This Page