I have this code, basically what i am trying to do is get the character information and what guild they are in and output it to a table. The thing I am having issues with is getting the guild NAME to display. I can get it to output the guildid, but not the name… anyone care to lend a hand? Thanks in advance!
Simplified, and trying to figure out how to use join
<?php
include ("../includes/config.php");
mysql_select_db($chardb_name, $chardb_connect) or die(mysql_error());
$query = "SELECT characters.name, guild.name
FROM characters INNER JOIN guild
ON guild_member.guid = characters.guid
WHERE guild_member.guildid = guild.guildid";
$result = mysql_query($query) or die(mysql_error());
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo $row['characters.name']. " - ". $row['guild.name'];
echo "<br />";
}
?>
<?php
include ("../includes/config.php");
mysql_select_db($chardb_name, $chardb_connect) or die(mysql_error());
$query = "SELECT characters.name AS cname, guild.name AS gname
FROM characters AS characters
LEFT JOIN guild_member AS guild_member ON guild_member.guid = characters.guid
LEFT JOIN guild AS guild ON guild.guildid = guild_member.guildid
WHERE guild_member.guid = characters.guid";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['cname']. " - ". $row['gname'];
echo "<br />";
}
?>