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

  • Home
  • SEARCH
  • 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 8279533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:22:36+00:00 2026-06-08T09:22:36+00:00

I’m working on a website to try and learn coding and am making a

  • 0

I’m working on a website to try and learn coding and am making a simple search site.

When the user searches for either “Restaurant” or “Restaurants” (or some other words but I’m just using these as examples), a list of words that could help refine the search such as “American Food” or “Chinese Food” appears. But there is quite a few refining words to choose from so I stored all of them in a database, and am using Javascript to display more ( when you first go there is a limit of 10 refining words on the page but when you click see more the rest appear.) Anyways, I thought that I would do a mysql select to show rows 1-10 and then another mysql select for rows 11 to the end of all the rows in the div that is not displayed until the user clicks see more. But I keep getting this error

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /Users/searchswitch.php on line 17

Warning: mysql_close(): 4 is not a valid MySQL-Link resource in /Users/searchswitch.php on line 22

What is causing this? Also, I know (even being a new programmer) that my code is not very clean, how can I clean this up)

Here’s the code: I left out the other switch cases to make it easier to read but if you need any more info, I’ll be glad to help! Thanks for all help!

switch ($q) {
            case "Restaurants" || "Restaurant":
                echo "<hr /><span><strong>Refine Search</strong><br/><br/>";
                $result = mysql_query("SELECT * FROM subcat WHERE catnumber='1' LIMIT 0,10");

                while($row = mysql_fetch_array($result))
                {
                    echo "<a href='search.php?q=". $row['subcat'] ."'/>" . $row['subcat'] ."</a>";
                    echo "<br />";
                }
                mysql_close($link);

                echo "<a href='#' id='example-show' class='showLink' onclick='showHide(\"example\");return false;'><br/>See more</a></span><div id='example' style='display:none;'>";
                $result = mysql_query("SELECT * FROM subcat WHERE catnumber='1' LIMIT 11,100");

                while($row = mysql_fetch_array($result))
                {
                    echo "<a href='search.php?q=". $row['subcat'] ."'/>" . $row['subcat'] ."</a>";
                    echo "<br />";
                }
                mysql_close($link);

                echo"<br/><a href='#' id='example-hide' class='hideLink' onclick='showHide(\"example\");return false;'>Hide</a></div>";

            break;

Oh also want to point out that line 17 is *while($row = mysql_fetch_array($result))* and line 22 is *mysql_close($link);*

  • 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-08T09:22:37+00:00Added an answer on June 8, 2026 at 9:22 am

    Use this your query will work fine

    switch ($q) {
            case "Restaurants" || "Restaurant":
                echo "<hr /><span><strong>Refine Search</strong><br/><br/>";
                $result = mysql_query("SELECT * FROM subcat WHERE catnumber='1' LIMIT 0,10");
    
                while($row = mysql_fetch_array($result))
                {
                    echo "<a href='search.php?q=". $row['subcat'] ."'/>" . $row['subcat'] ."</a>";
                    echo "<br />";
                }
    
    
                echo "<a href='#' id='example-show' class='showLink' onclick='showHide(\"example\");return false;'><br/>See more</a></span><div id='example' style='display:none;'>";
                $result = mysql_query("SELECT * FROM subcat WHERE catnumber='1' LIMIT 11,100");
    
                while($row = mysql_fetch_array($result))
                {
                    echo "<a href='search.php?q=". $row['subcat'] ."'/>" . $row['subcat'] ."</a>";
                    echo "<br />";
                }
    
    
                echo"<br/><a href='#' id='example-hide' class='hideLink' onclick='showHide(\"example\");return false;'>Hide</a></div>";
    
            break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.