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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:49:19+00:00 2026-06-13T01:49:19+00:00

I need a query to search a database for a specific number within a

  • 0

I need a query to search a database for a specific number within a group of numbers listed in the same column on a database.

The database Access will contain two columns

First column: Page Name

Second Column: Access

And will be set up similar to: Page Name: Blog-Admin Access: 60,61,62,76,83,94

where the numbers in the column Access are the ranks that are allowed to view the page.

On each page, there will be a query that finds the users rank and stores it in a $URank variable.

Each page is named in a variable ($PageName) which will match the column Page Name in the Access Database

In this query, it needs to search the column Access for the users rank for that page (page name = $PageName)

By storing this in a database, it will allow admins to modify who has access to what pages at any point in time.

I just need the query that will search the database to make sure that user rank has permission to access that page.

This may be very simple, not sure.

I’m use to queries such as mysql_query(“select * from database where blahblah=viarable”)…so if it could be answered in this format, that would be fantastic. Even if its the mysqli equivilant.

  • 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-13T01:49:20+00:00Added an answer on June 13, 2026 at 1:49 am

    EDIT: Okay, it sounds like what you’re doing is storing a string of allowed ranks in the Access column. This is a very bad idea. It’s hard to manage and requires a lot of extra work in PHP. What you should do instead is use two tables, structured something like this:

    create table Pages (
        id int primary key auto_increment,
        name varchar(200)
    );
    
    create table Page_access (
        page_id int,
        rank int
    );
    

    So, you’d store a list of all your pages (and nothing else) in the Pages table. Then, add to the Page_access table all the possible combinations of page IDs (from the Pages table) and accepted user ranks for those pages, so Page_access might look something like:

    |page_id | rank |
    |   1    |  60  |
    |   1    |  61  |
    |   1    |  62  |
    |   2    |  70  |
    |   2    |  71  |
    

    … etc. This means you might end up with hundreds of rows in your table—that’s okay! It’s a normalized table and if you index the columns performance will not be affected.

    Alternately, if you know you’re always going to accept a rank within a range, you could structure your Page_access table like this:

    create table Page_access (
        page_id int,
        min_rank int,
        max_rant int
    );
    

    Then just check if the user’s rank is between the min and max ranks for the page using SQL’s between. I hope this helps with organizing your tables, but I know it still doesn’t answer your original question (how to write the SQL statements). I’d recommend making sure you’ve got a good table structure down, then ask another, more specific question once you’ve tried writing the actual queries.


    Original answer:

    Assuming you’re using mysqli:

    #connect to your database
    $mysqli = new mysqli('localhost', $database_username, $database_password, 'Access');
    
    #prepare and run the query
    if($stmt = $mysqli->prepare('select URank from Access where URank = ?')) {
        $stmt->bind_param('i', $URank);
        $stmt->execute();
        $stmt->bind_result($exists);
        $stmt->fetch();
    
        if($exists) {
            #the URank was found in the table
        } else {
            #not found
        }
        $stmt->close();
    }
    

    Something like that should do the trick. I encourage you to read up on mysqli and prepared statements before using my example above. You really need to understand what you’re doing when writing database queries.

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

Sidebar

Related Questions

I need a query to search phone number. Simple searching is fine, but I
i need to submit a query to search posts with a specific tag. the
I have many buttons in a button group that need to search a database
I have a table in MS Access database and need to create a query
What I need is when the user types his query in the search Box.
I need to implement a Query Object Pattern in Java for my customizable search
Need to query my SQL server from Access using an ADO connection (for example),
I need to query statistics about duplicate values in my database table. For example,
I need to query large amount of data from a database via C# and
I have a number of search/text boxes that, using AJAX, search database tables and

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.