Hey guys, I am sure there is a simple solution to this but im not seeing it.
I am trying to select values from two tables to poplulate a menubar. Im getting the correct records but one of the records is duplicated 3 times, but there are not 3 duplicate records. here is the code:
[php]<?php
connect();
$query=“SELECT * FROM navbar, users WHERE (navbar.location=‘0’) OR (navbar.location=users.location AND users.username=’$_SESSION[myusername]’)”;
$result = mysql_query($query) or die($query."
".mysql_error());
while($row = mysql_fetch_array($result))
{
echo “
” . $row[‘name’] . “
}
mysql_close();
?>[/php]
navbar.location=‘0’ is the one thats producing 3 duplicate records, the other records come out fine.
The tables look something like this
table: navbar
ID Name URL Location |
---|
1 |
2 | email | www.u.com | 0 |
and table: users
------------------------------------------|
ID username password location |
---|
1 |
2 |
-------------------------------------------- |
Im basically making 2 homepages for 2 store locations. the buttons with location 0 will be on the navigation bars at both webpages. the buttons with location 1 will be for store A’s page and the buttons for store B are location 2.
Any pointers? thanks in advance!