• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [PHP+SQL] Looking for a script

Kavvson

Gdy boli cie glowa wez
Joined
Jun 25, 2008
Messages
1,177
Reaction score
72
Location
Poland
Im searching for a script that will display all characters from a account. Stand alone code please. I know it will be like that



// New edit
PHP:
	<?PHP

 $get = $mysqli->query ("SELECT `name` FROM `players` WHERE `account_id` = `".$accountresult['name']."`");
 
 foreach($get as $character){		
 
echo "".$character['name']."";
}
 
?>

and dont work
 
Last edited:
$mysqli = new mysqli( 'localhost', 'root', '', 'test' );
Yes



PHP:
$accountresult = $mysqli->query( 'SELECT * FROM `players` LEFT JOIN `accounts` ON `accounts`.`id` = `players`.`account_id` WHERE `players`.`name` = \''.$mysqli->real_escape_string( $_GET['editcharacter'] ).'\';' )->fetch_assoc( );  
  

     $get = $mysqli->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".$accountresult['name']."");   
          
       foreach($get as $player)   
       {   
         echo " ".$player['name']." ";
       }

Dont work
 
try:
PHP:
<?PHP
	$mysqli = new mysqli('localhost', 'root', 'pass', 'db'); 
	$accountresult = $mysqli->query('SELECT * FROM `players` LEFT JOIN `accounts` ON `accounts`.`id` = `players`.`account_id` WHERE `players`.`name` = "'.$mysqli->real_escape_string( $_GET['editcharacter'] ).'";' )->fetch_assoc( );
	$get = $mysqli->query("SELECT `name` FROM `players` WHERE `account_id` = ".$accountresult['account_id']."");
	while($character = $get->fetch_object()) {
		echo "".$character->name."<br/>";
	}
 
?>
 
@ up sorry now it works :p

PHP:
 $get = $mysqli->query("SELECT `name` FROM `players` WHERE `account_id` = ".$accountresult['account_id']."");
    while($character = $get->fetch_object()) {
        echo "".$character->name."<br/>";
    }

all is ok thanks rep :)


------------------------------------------------------------

Btw. Xampy is it possible to connect a tooltip?
PHP:
<div id="character">
<a title="
	<?PHP $tab = array(
	 'Name' => 'name',
     'Level' => 'level',
     'Experience' => 'experience',
     'Vocation' => 'vocation',
     'Page Access' => 'maglevel',
	 'Promotion' => 'promotion',
	 'Sex' => 'sex',
     'Guild Nick' => 'guildnick',
     'Health' => 'health',
     'Healthmax' => 'healthmax',
     'Mana' => 'mana',
     'Manamax' => 'manamax',
	 'Soul' => 'soul',
     'Capability' => 'cap');
    
    foreach($tab as $key => $value)
    {
        echo $key.' : '.$result[$value].'<br />';
    }
	?>" href="#"><?PHP ECHO $result['name']; ?></a>

</div>

with the script

PHP:
 $get = $mysqli->query("SELECT `name` FROM `players` WHERE `account_id` = ".$accountresult['account_id']."");
    while($character = $get->fetch_object()) {
        echo "".$character->name."<br/>";
    }
 
Last edited:
@ up sorry now it works :p
Btw. Xampy is it possible to connect a tooltip?
PHP:
<div id="character">
<a title="
	<?PHP $tab = array(
	 'Name' => 'name',
     'Level' => 'level',
     'Experience' => 'experience',
     'Vocation' => 'vocation',
     'Page Access' => 'maglevel',
	 'Promotion' => 'promotion',
	 'Sex' => 'sex',
     'Guild Nick' => 'guildnick',
     'Health' => 'health',
     'Healthmax' => 'healthmax',
     'Mana' => 'mana',
     'Manamax' => 'manamax',
	 'Soul' => 'soul',
     'Capability' => 'cap');
    
    foreach($tab as $key => $value)
    {
        echo $key.' : '.$result[$value].'<br />';
    }
	?>" href="#"><?PHP ECHO $result['name']; ?></a>

</div>

with the script

PHP:
 $get = $mysqli->query("SELECT `name` FROM `players` WHERE `account_id` = ".$accountresult['account_id']."");
    while($character = $get->fetch_object()) {
        echo "".$character->name."<br/>";
    }
Yes, all is possible in this world xD.
 
Could you try it? I assume you do it better then I ;) Btw could you add in your

PHP:
 <?PHP
   
  $get = $mysqli->query("SELECT `name` FROM `players` WHERE `account_id` = ".$accountresult['account_id']."");
    while($character = $get->fetch_object()) {
        echo "".$character->name."<br/>";
    }
?>

Sth like that

".$character->name." ($player lvl)


@ i tried the tooltip its a bit hard i get much display errors;P but its possible.
What about the ".$character->name." ($player lvl)
 
Last edited:
Here it is (improved):
PHP:
<?PHP
	$mysqli = new mysqli('localhost', 'root', 'password', 'database'); 
	$accountresult = $mysqli->query('SELECT * FROM `players` LEFT JOIN `accounts` ON `accounts`.`id` = `players`.`account_id` WHERE `players`.`name` = "'.$mysqli->real_escape_string( $_GET['editcharacter'] ).'";' )->fetch_assoc( );
	$get = $mysqli->query("SELECT * FROM `players` WHERE `account_id` = ".$accountresult['account_id']."");
	if($get == TRUE) {
		while($character = $get->fetch_object()) {
			echo "".$character->name." (".$character->level.")<br/>";
		}
	}
	else
		echo '<b>This character does not exist:</b> <font color="red">'.$_GET['editcharacter'].'</font>';
 
?>
 
So you have your script : that shows chars in 1 account. I have a tooltip that looks like this


and the output is :
149tn29.jpg


This is my example how could it be its totally not correct just see how could it be

PHP:
   $get = $mysqli->query("SELECT * FROM `players` WHERE `account_id` = ".$accountresult['account_id']."");

<a title="
    <?PHP $tab = array(
     'Name' => 'name',
     'Level' => 'level',
     'Experience' => 'experience',
     'Vocation' => 'vocation',
     'Page Access' => 'maglevel',
     'Promotion' => 'promotion',
     'Sex' => 'sex',
     'Guild Nick' => 'guildnick',
     'Health' => 'health',
     'Healthmax' => 'healthmax',
     'Mana' => 'mana',
     'Manamax' => 'manamax',
     'Soul' => 'soul',
     'Capability' => 'cap');
    
    foreach($tab as $key => $value)
    {
        echo $key.' : '.$result[$value].'<br />';
        
    }
    
    ?>" href="#">
    
    while($character = $get->fetch_object()) {
            echo "".$character->name." (".$character->level.")<br/>";
        }
</a>
 
Try:
PHP:
<?PHP
	$mysqli = new mysqli('localhost', 'root', 'password', 'database'); 
	$accountresult = $mysqli->query('SELECT * FROM `players` LEFT JOIN `accounts` ON `accounts`.`id` = `players`.`account_id` WHERE `players`.`name` = "'.$mysqli->real_escape_string( $_GET['editcharacter'] ).'";' )->fetch_assoc( );
	$get = $mysqli->query("SELECT * FROM `players` WHERE `account_id` = ".$accountresult['account_id']."");

	while($character = $get->fetch_object()) {
	echo '<a title="';
	$tab = array(
     'Name' => 'name',
     'Level' => 'level',
     'Experience' => 'experience',
     'Vocation' => 'vocation',
     'Page Access' => 'maglevel',
     'Promotion' => 'promotion',
     'Sex' => 'sex',
     'Guild Nick' => 'guildnick',
     'Health' => 'health',
     'Healthmax' => 'healthmax',
     'Mana' => 'mana',
     'Manamax' => 'manamax',
     'Soul' => 'soul',
     'Capability' => 'cap');
    
		foreach($tab as $key => $value)
		{
			echo $key.': '.$character->$value.'<br/>';
		}
		echo "\" href=\"#\">".$character->name."</a><br/>";
	}
?>
 
Back
Top