Forum Moderators: coopster
Thank you for any help.
This is my code
##Connect to Character Database
$cresult = mysql_query("SELECT * FROM user_char", $link) or die ("query 1: " . mysql_error());
$crow = mysql_fetch_array($cresult) or die ("query 2: " . mysql_error());
##Beginning table inside inner Table, User information
echo '<table border="1" cellpadding="5" cellspacing="0">'
. '<tr><th colspan="2" align="width">Account Information</th></tr>'
. '<tr><td width="100">Username</td><td width="200">'.$urow[username].'</td></tr>'
. '<tr><td width="100">Email</td><td width="200"><form action="'.$php_self.'" method="post"><input type="text" name="email" value="'.$urow[email].'" /><input type="submit" name="updateemail" value="Update Email"/></form></td></tr>'
. '</table>';
##End user information table
echo '</td><td>';
if ($username == $crow[username]){
##Begin 2nd table inside inner table, Character information
echo '<table border="1" cellpadding="5" cellspacing="0">'
. '<tr><th colspan="2" align="center">Character Information</th></tr>'
. '<tr><td width="100">Race</td><td width="200">'.$crow[race].'</td></tr>'
. '<tr><td width="100">Rank</td><td width="200">'.$crow[rank].'</td></tr>'
. '<tr><td width="100">Gold</td><td width="200">'.$crow[gold].'</td></tr>'
. '<tr><td width="100">Name</td><td width="200">'.$crow[name].'</td></tr>'
. '<tr><td width="100">Weapon</td><td width="200">'.$crow[weapon].'</td></tr>'
. '<tr><td width="100">Helmet</td><td width="200">'.$crow[helmet].'</td></tr>'
. '<tr><td width="100">Armor</td><td width="200">'.$crow[armor].'</td></tr>'
. '<tr><td width="100">Bracers</td><td width="200">'.$crow[bracers].'</td></tr>'
. '<tr><td width="100">Gloves</td><td width="200">'.$crow[gloves].'</td></tr>'
. '<tr><td width="100">Greaves</td><td width="200">'.$crow[greaves].'</td></tr>'
. '<tr><td width="100">Boots</td><td width="200">'.$crow[boots].'</td></tr>'
. '</table>';
##End Character Information table
}
else
{
##Echo the Create a Character form
echo '<table border="1" cellspacing="0" cellpadding="4"><tr>'
. '<th colspan="2">Create A Character</th></tr>'
. '<tr><td>Charcter Name</td><td><form action="account.php" method="post"<input type="text" name="charname"/></td></tr>'
. '<tr><td>Race</td><td><select name="charrace"><option value="Human">Human<option value="Orc">Orc</select></td></tr>'
. '<tr><td colspan="2"><input type="submit" name="createchar" value="Create"/></form></td></tr></table>';
##End the create a character form
}
$cresult = mysql_query("SELECT * FROM user_char WHERE username='".$username."'", $link) or die ("query 1: " . mysql_error());
Adding the WHERE clause makes sure you only pickup the character info belonging to that username. It might cause problem down the line if there's no returned result, like someone without a character yet. But I'd start with that.
Hope that helps.
mavherick
if (mysql_num_rows($cresult) > 0) {
$crow = mysql_fetch_array($cresult) or die ("query 2: " . mysql_error());
....
mavherick