PCHomepage
Programmer
At first I tried a joined query which must join between two different databases but, as the site was created by a code generator (CodeCharge Studio) which seems to have its own way of doing things, I was unable to get it to work. Therefor I rewrote it a bit and used a lookup query within the WHILE loop and it is working but I can think of no way to sort the results alphabetically. Any ideas or is there some way to do the joined query? See the red code below, which I'm sure is filled with errors (it was late; I was tired!) but it illustrates what I originally tried to do.
Code:
$db1 = new clsDBconn();
$db2 = new clsDBgeoip();
$queryCat = "SELECT DISTINCT Country
FROM guestbook";
/*[COLOR=red]
$queryCat = "SELECT DISTINCT db1.g.Country AS CountryID, db2.c.CountryName AS Country
FROM db1.guestbook g, db2.countries c
WHERE db1.g.Country = db2.c.ID
AND db1.g.Country <> ''
ORDER BY db2.c.CountryName";
[/color]*/
$db1->query($queryCat);
while ($db1->next_record()) {
$CountryID= $db1->f("Country");
$CountryText = CCDLookUp("CountryName","countries","ID=".$CountryID,$db2);
$CountryLink = "/php/guestbook.php?Country=".$CountryID;
}