Aargh ! Sorry that was loose of me. Yes it works now and thank you. I do have trouble using joins and i guess when i try to eliminate it , i end up with the many loops. I hope i can improve.
Although i am marking this thread as solved, heres' why i have trouble with joins. If i want to get the value of $cgid and then list out all cos with their addresses i cannot do it. cgid is a value that occurs only in the customers table ( structure - cid, cgid and company)
$sqla = "SELECT * FROM `Customers` WHERE `Company` LIKE '%$customer%' ORDER BY `Company` asc";
$resulta = mysql_query($sqla) or die (mysql_error ());
if ($myrowa = mysql_fetch_array($resulta));
$cgid = $myrowa["CGID"];
$resultc = mysql_query("SELECT * FROM Custaddress INNER JOIN Customers ON Custaddress.CID WHERE (Custaddress.CID = $cid || Customers.CGID = $cgid) ORDER BY `Company` asc ");
By doing this i had hoped to get not only all companies that match '%$customer% but others in the same group. Anyway i dont get a result with the above query so its also wrong.
Example: '%$customer% = nation . This will yield nation, national, international . But if nation and subcontinent are 2 companies of the same group say 1 , then when i run $sql, i not only want nation, national, international to get listed but also subcontinent. And thats where the join gives me problems.
Any ideas ? Thanks.
Thanks again !
Swati