Creating a table with DB items[SOLVED]
Posted: Wed Oct 05, 2011 8:28 pm
Title sounds kind of weird, oh well. Sorry for posting again, I am a newbie programmer 
Well, when a player clicks on 'Warriors' I'd like it to show a table with all their characters and some of the characters info.
However, it is only pulling the users 1st character and putting it in the table, instead of all his characters.
Here is my code
Here's the picture of what it looks like...
http://gyazo.com/fb08a554db42645277106c22b4047cc8
It should be pulling all that users characters.
Well, when a player clicks on 'Warriors' I'd like it to show a table with all their characters and some of the characters info.
However, it is only pulling the users 1st character and putting it in the table, instead of all his characters.
Here is my code
Code: Select all
<?php
error_reporting(E_ALL);
include_once 'connect.php';
session_start();
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
header( 'Location: http://localhost/warrior/login.php' );
exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$warriorinfo="SELECT * from warriors where pname='$player'";
$warriorinfo2=mysql_query($warriorinfo) or die("could not get player stats!");
$warriorinfo3=mysql_fetch_array($warriorinfo2);
$name=$warriorinfo3['name'];
$level=$warriorinfo3['level'];
$gold=$warriorinfo3['gold'];
$speed=$warriorinfo3['speed'];
$power=$warriorinfo3['power'];
$melee=$warriorinfo3['melee'];
$mage=$warriorinfo3['magic'];
$arch=$warriorinfo3['archery'];
$meldef=$warriorinfo3['meleedef'];
$magedef=$warriorinfo3['magedef'];
$archdef=$warriorinfo3['archerydef'];
$def=$warriorinfo3['defense'];
$vision=$warriorinfo3['vision'];
$health=$warriorinfo3['health'];
$agility=$warriorinfo3['agility'];
$dungs=$warriorinfo3['dungeons'];
$battles=$warriorinfo3['battles'];
$type=$warriorinfo3['ptype'];
$exp=$warriorinfo3['exper'];
$cid=$warriorinfo3['cid'];
$total= $speed + $power + $melee + $mage + $arch + $meldef + $magedef + $archdef + $def + $vision + $health + $agility;
print "<p><table border='1'>";
print "<th>Warrior</th><th>Level</th><th>Total Levels</th><th>Experience</th><th>Gold</th><th>Dungeons</th><th>Battles</th><th>Type</th><th>Play</th>";
print "<tr>";
print "<td>$name</td><td>$level</td><td>$total</td><td>$exp</td><td>$gold</td><td>$dungs</td><td>$battles</td><td>$type</td><td><a href='playwar.php?&warrior=$cid'>Play</a></td>";
print "</table>"
?>http://gyazo.com/fb08a554db42645277106c22b4047cc8
It should be pulling all that users characters.