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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:29:22+00:00 2026-06-15T17:29:22+00:00

I have two tables, customers and users. In the customers table, I have a

  • 0

I have two tables, “customers” and “users”.

In the customers table, I have a column titled “name”. This has all customer names.

In my users table, I have a column titled “managing”. This has certain customer names.

I am trying to display content if “managing” CONTAINS ANY customer from “name”.

Here is an example…

“name” contains customers “applebees”, “johnny carinos”, and “pizza hut”.

User rick is “managing” “applebees” and “pizza hut”. In his row/the column, it looks like “applebees,pizza hut” (i am using the implode function which is why there is a ,”)

So, on my customers page, I want rick to see applebees and pizza hut. I do NOT want to him to see johnny carinos, since he isn’t managing it.

How can I do this? I’ve tried preg match & strpos but failed miserably. (I’m still rather new to php). This would be much easier of it was a single value, so I can just set value = value. Unfortunately, having multiple values for “managing” really messes me up!

Hope this made sense. Thanks for any help!

Here’s what I have now (yes, i know, it’s terribly wrong, probably.)

<?php


$sql = "SELECT * FROM customers";
$result = mysql_query($sql);
        $thecust = $_SESSION['user']['managing'];
    $thecustomers = htmlentities($row['name']);


    $check = strprk(wing, $thecust);
    if ($check) {

while ($row = mysql_fetch_array($result)) {
?>

    <tr> 
        <td><?php echo "<a href='customer.php?id=" . $row['id'] . "'>" . $row['name'] . "</a>"?></td> 
        <td><?php echo htmlentities($row['contact_name'], ENT_QUOTES, 'UTF-8'); ?></td> 
        <td><?php echo htmlentities($row['contact_number'], ENT_QUOTES, 'UTF-8'); ?></td> 
        <td><?php echo htmlentities($row['contact_email'], ENT_QUOTES, 'UTF-8'); ?></td> 
    </tr> 

<? } ?>
  • 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-15T17:29:22+00:00Added an answer on June 15, 2026 at 5:29 pm

    The answer lies in your database schema and the way you query it. You didn’t really get into your DB table structure but I would propose you use something like this

    users
    -------
    user_id INT, autoincrement, PRIMARY KEY
    user_name VARCHAR
    [other user-specific fields]
    
    users_to_customers
    -------
    user_id INT
    customer_id INT
    [compound primary key across both fields]
    
    customers
    -------
    customer_id INT, autoincrement, PRIMARY KEY
    customer_name VARCHAR
    [other customer specific fields]
    

    Note I have three tables here. This allows you to relate any number of users to any number of customers. NOw to get teh information you are looking for, let’s assume you know the user_id of the user viewing the customers page. You query might look like

    SELECT c.customer_id, c.customer_name, [whatever other fields you need]
    FROM users AS u
    INNER JOIN users_to_customers AS uc
    INNER JOIN customers AS c
    WHERE u.user_id = ? [the user_id of the user viewing the page]
    

    This will give you customer information for those customers related to the the user.


    You also should not be using the mysql_* functions are they are deprecated (note the big red warning in PHP.net documentation). perhaps use mysqli_* functions.

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

Sidebar

Related Questions

I have the following two tables: Customer { int Id int Name } Bills
I have two tables one with ID and NAME table 1 ID | NAME
I have two types of customers in a table, privileged and normal users. When
If I have two tables, Customers and Orders, and I want to look up
I have two tables in my database that look like that: Customer: C_ID city
I have two tables, one with products and a foreign key for the customer.
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables set up in a many-to-many relationship: Incidents and Users. When
I have two tables, Customer and CustomerPhone. Single record in Customer can have multiple
I have two tables, customers and bank accounts, with a many-to-many relationship (each user

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.