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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:37:02+00:00 2026-06-05T02:37:02+00:00

So I’m building a search site where there is a PHP/ mySQL search and

  • 0

So I’m building a search site where there is a PHP/ mySQL search and a javascript “show this number of results per page” HTML select which is submitted with the number per page that the user desires and then refreshes the search page. Unfortunately, when I loaded the page I got three errors. With the if (isset($_POST['select'])){ $total_pages == $_POST['select'];} just set to $total_pages = 12 it works fine?

  • Notice: You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near ” at line 1 in /Users/Me/Sites/mySite/search.php on line 36
  • Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Users/Me/Sites/mySite/search.php on line 37
  • Warning: Division by zero in /Users/Me/Sites/mySite/search.php on line 104

Here is the code:

<?php

    $q = mysql_real_escape_string(ucfirst(trim($_REQUEST['searchquery'])));

        if (isset($q)){
        if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1;
        if (isset($_POST['select'])){ $total_pages == $_POST['select'];} //Here edit the amount per page 
        $record_start = ($page * $total_pages) - $total_pages;
            REQUIRE('config.php');

            $result = mysql_query("SELECT * FROM companies WHERE company_name LIKE '%$q%' OR company_description LIKE '%$q%' OR cat1 LIKE '%$q' OR cat2 LIKE '%$q' OR cat3 LIKE '%$q' OR company_phone LIKE '%$q' ORDER by company_name LIMIT $record_start,$total_pages") or trigger_error(mysql_error());
            $rows = mysql_num_rows($result);

            $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM companies"),0); 
            echo "
            <h4>Search for &quot;$q&quot;</h4>
             <div class='right'>
                <div class='textad1'>
                    <center>

                        <form name='form1' method='post'>
                            Results per Page:
                            <select name='select' onChange='document.form1.submit()'>
                                <option value='10'";if($_REQUEST['select'] == 12) {echo "selected='selected'";} echo">12</option>
                                <option value='15'";if($_REQUEST['select'] == 18) {echo "selected='selected'";} echo">18</option>
                                <option value='25'";if($_REQUEST['select'] == 32) {echo "selected='selected'";} echo">32</option>
                            </select>
                        </form>

                   </center>
                </div>
                <div class='divider'></div>
            </div>
            <div class='left'>

            <ul>";
        while($row = mysql_fetch_array($result))

If you need any more code, I will quickly get you that. Any help will be greatly appreciated!

  • 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-05T02:37:03+00:00Added an answer on June 5, 2026 at 2:37 am

    I think your code should be like this,

    require('config.php');
    $q = mysql_real_escape_string(ucfirst(trim($_REQUEST['searchquery'])));
    
        if (isset($q)){
        if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1;
        if (isset($_POST['select'])){ $total_pages = $_POST['select'];} //Here edit the amount per page 
        $record_start = ($page * $total_pages) - $total_pages;
    
            $result = mysql_query("SELECT * FROM companies WHERE company_name LIKE '%$q%' OR company_description LIKE '%$q%' OR cat1 LIKE '%$q' OR cat2 LIKE '%$q' OR cat3 LIKE '%$q' OR company_phone LIKE '%$q' ORDER by company_name LIMIT $record_start,$total_pages") or trigger_error(mysql_error());
            $rows = mysql_num_rows($result);
    
            $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM companies"),0); 
    
    //code continuation
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.