player list and player link [resolved]

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
bultrayer
Posts: 10
Joined: Tue Jan 22, 2013 7:52 am

player list and player link [resolved]

Post by bultrayer »

Alright i have built , followed the guide building the browser game , built it finnaly and now i'am planning to make an attack page ,
means , a page that will show players in pages , it will show gold and points as well , the ranking will be ordered by points.

As well now you can see my page with the list :
http://prntscr.com/q199g

But i can't figure how to make links for users , like a profile link for every user.
something like that : http://www.oryzhon.com/vw/rank.php

Any one could help me with that?

Thats my script :

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';

$result = mysql_query("SELECT * FROM players ORDER BY id");

while($row = mysql_fetch_array($result))
  {
  echo $row['id'];
  echo " " . $row['name'];
  echo " " . $row['gold'];
  echo "<br>";
  }

?>
Thanks
Last edited by bultrayer on Wed Jan 23, 2013 3:13 pm, edited 1 time in total.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: player list and player link

Post by hallsofvallhalla »

Code: Select all

while($row = mysql_fetch_array($result))
  {
  echo $row['id'];
  echo " <a href='yourpage.php?id=" . $row['id'] . "' >" . $row['name'] . "</a>";
  echo " " . $row['gold'];
  echo "<br>";
  }
then on yourpage.php or whatever you wanna call it get the id from the get method and make a db call

Code: Select all

$playerid = $_GET['id'];
$Oplayerinfo="SELECT * from players where id='$playerid'";
$Oplayerinfo2=mysql_query($Oplayerinfo) or die("could not get player stats!");
$Oplayerinfo3=mysql_fetch_array($Oplayerinfo2);
bultrayer
Posts: 10
Joined: Tue Jan 22, 2013 7:52 am

Re: player list and player link

Post by bultrayer »

hallsofvallhalla wrote:

Code: Select all

while($row = mysql_fetch_array($result))
  {
  echo $row['id'];
  echo " <a href='yourpage.php?id=" . $row['id'] . "' >" . $row['name'] . "</a>";
  echo " " . $row['gold'];
  echo "<br>";
  }
then on yourpage.php or whatever you wanna call it get the id from the get method and make a db call

Code: Select all

$playerid = $_GET['id'];
$Oplayerinfo="SELECT * from players where id='$playerid'";
$Oplayerinfo2=mysql_query($Oplayerinfo) or die("could not get player stats!");
$Oplayerinfo3=mysql_fetch_array($Oplayerinfo2);
the id it redirects me to http://www.mywebsite.com/yourpage.php?i ... i-selected
then on this page i placed the code :

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';

$playerid = $_GET['id'];
$Oplayerinfo="SELECT * from players where id='$playerid'";
$Oplayerinfo2=mysql_query($Oplayerinfo) or die("could not get player stats!");
$Oplayerinfo3=mysql_fetch_array($Oplayerinfo2);

?>
on yourpage.php

It doesn't show me anything ? why?
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: player list and player link

Post by hallsofvallhalla »

make sure the id is returned a ID that is in the DB

Code: Select all

$playerid = $_GET['id'];
echo "id posted:' . $playerid;
$Oplayerinfo="SELECT * from players where id='$playerid'";
$Oplayerinfo2=mysql_query($Oplayerinfo) or die("could not get player stats!");
$Oplayerinfo3=mysql_fetch_array($Oplayerinfo2);

echo "<br>id selected:" . $Oplayerinfo3['name'];
bultrayer
Posts: 10
Joined: Tue Jan 22, 2013 7:52 am

Re: player list and player link

Post by bultrayer »

Okay thank you already dealt with it , found somehow to fix it.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: player list and player link

Post by hallsofvallhalla »

if it is fixed please mark post with resolved.

thanks glad you got it working!
Post Reply

Return to “Advanced Help and Support”