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>
<? } ?>