Jump to content

More Than 1


Cooper94

Recommended Posts

<?php include 'db.php';

  if (isset($_GET['id'])) {
    $sql = "SELECT name,level,vocation,sex,id FROM players WHERE name='{$_GET['id']}'";
    if ($result = mysql_query($sql)) {
      $row = mysql_fetch_assoc($result);
    } else {
    echo "query failed ".mysql_error();
    }
  } else {
    echo "No User Selected";
  } ?>

<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR=#505050><TD COLSPAN=2 CLASS=white><B>Character Information</B></TD></TR><TR BGCOLOR=#F1E0C6>
<TD WIDTH=20%>Name:</TD><TD><?php echo $row['name']; ?></TD></TR>
<TR BGCOLOR=#D4C0A1><TD>Sex:</TD><TD><?php echo $row['sex']; ?></TD></TR>
<TR BGCOLOR=#F1E0C6><TD>Profession:</TD><TD><?php echo $row['vocation']; ?></TD></TR>
<TR BGCOLOR=#D4C0A1><TD>Level:</TD><TD><?php echo $row['level']; ?></TD></TR>
<TR BGCOLOR=#D4C0A1><TD>Account&#160;Status:</TD><TD>Donator</TD></TR></TABLE>

<?php
$sqlss = "SELECT * FROM player_deaths WHERE killed_by = '{$row['name']}' AND is_player = '1'";
$resultss = mysql_query($sqlss);
$rowss = mysql_fetch_assoc($resultss);
?>

<?php
$results = mysql_query("SELECT * FROM players WHERE id = '{$rowss['player_id']}'");
$nums = mysql_num_rows($results);
while ($rows = mysql_fetch_array($results))
{
echo "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>";
echo "<TR BGCOLOR=#505050><TD COLSPAN=3 CLASS=white><B>Player Kills</B></TD></TR>";
echo "<TD BGCOLOR=#D4C0A1>Killed $rows[name]</TD>";
echo "<TD BGCOLOR=#D4C0A1 WIDTH=40%>This Killing Was Unjustified</TD></TR>";
echo "</table>";
}
?>

 

When it displays the player kills:

 

<?php
$results = mysql_query("SELECT * FROM players WHERE id = '{$rowss['player_id']}'");
$nums = mysql_num_rows($results);
while ($rows = mysql_fetch_array($results))
{
echo "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>";
echo "<TR BGCOLOR=#505050><TD COLSPAN=3 CLASS=white><B>Player Kills</B></TD></TR>";
echo "<TD BGCOLOR=#D4C0A1>Killed $rows[name]</TD>";
echo "<TD BGCOLOR=#D4C0A1 WIDTH=40%>This Killing Was Unjustified</TD></TR>";
echo "</table>";
}
?>

 

It only shows one and I made sure there are more than 1 on the database. Is there something noticeably wrong to you guys? I thank you for the help and hope to see some answers thank you!

 

Link to comment
Share on other sites

I can't remember exactly what mysql_fetch_array() does, I tend to use mysql_fetch_assoc() in situations similar to what you're trying to achieve.

 

I'm not entirely sure what you're trying to achieve in the first part of code you posted with the raw HTML and various other bits of code mish-mashed all over the place. But the second bit of code you posted should do what you want it to do assuming that $rowss['player_id'] contains what you're expecting and that a database connection has been set up before the query is made.

 

Also, you might want to put the echo <table....> line before the while loop, and the echo </table> line after the closing } of the while loop. Otherwise, those tags are going to be repeated for every row - giving you lots of tables that only contain 1 row, instead of 1 table that contains a lot of rows.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.