Register for your free account! | Forgot your password?

You last visited: Today at 23:12

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



PHP frage

Discussion on PHP frage within the Metin2 Private Server forum part of the Metin2 category.

Reply
 
Old   #1
 
F4m0uZStYle's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 284
Received Thanks: 87
PHP frage

Halli hallo

ich hab ne frage zu einer gildenrangliste,und zwar:wenn ich den leader raus lesen will,zeigt er mir nur die ID des Leaders an.

meine frage jetzt:wie kann ich es so auslesen lassen das der name des Leader da steht und nicht die ID?
F4m0uZStYle is offline  
Old 09/16/2011, 04:11   #2
 
elite*gold: 0
Join Date: Sep 2011
Posts: 40
Received Thanks: 19
Bearbeite den SQL Query, dann wird's funktionieren.
AIR7 is offline  
Old 09/16/2011, 05:51   #3
 
F4m0uZStYle's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 284
Received Thanks: 87
ja das schon kla,aber ich weiß nicht wie bzw was ich da eintragen soll


PHP Code:
<?php 
echo "<center><table border=\"0\">
    <tr>
    <td width=\"30\"><b><center>Platz</center></b></td>
    <td width=\"200\"><b><center>Name</center></b></td>
    <td width=\"30\"><b><center>Level</center></b></td>
    <td width=\"150\"><b><center>Punkte</center></b></td>
    <td width=\"60\"><b><center>Gewonnen</center></b></td>
    <td width=\"60\"><b><center>Unentschieden</center></b></td>
    <td width=\"60\"><b><center>Verloren</center></b></td>
    <td width=\"60\"><b><center>Reich</center></b></td>
    </tr>"
;
 include 
'inc/dbsettings.php';
    
$db    "player";
    
mysql_connect($dbhost$dbuser$dbpw) OR
    die(
"ERROR: Connection failed. ".mysql_error());        
    
mysql_select_db($db) OR
    die(
"ERROR: DB allready open. ".mysql_error());
$sql "SELECT * FROM guild ORDER BY ladder_point desc, exp desc";
      
$i "0" ;
 
$ergebnis mysql_query($sql);
while(
$row mysql_fetch_object($ergebnis))
   {
   
$i $i ;
    
$leader $row->master;
   echo 
"
  <tr>
    <th width=\"40\"><font color=#FFFFFF>
$i</font></th>
    <th width=\"200\"><font color=#FFFFFF>
$row->name</a></font></th>
    <th width=\"60\"><font color=#FFFFFF>
$row->level</font></th>
    <th width=\"150\"><font color=#FFFFFF>
$row->ladder_point</font></th>
    <th width=\"150\"><font color=#FFFFFF>
$row->win</font></th>
    <th width=\"150\"><font color=#FFFFFF>
$row->draw</font></th>
    <th width=\"150\"><font color=#FFFFFF>
$row->loss</font></th>";
    
$reich mysql_query("SELECT empire from player_index where pid1 = '$leader' OR pid2 = '$leader' OR pid3 = '$leader' OR pid4 = '$leader'");
    
$reich2 mysql_fetch_object($reich);
    
$empire $reich2->empire;
    if(
$empire == 1) {
                echo 
"<th width=\"150\"><img src=\"img/shinsoo.jpg\"></th></tr>";
                } elseif(
$empire == 2) {
                echo 
"<th width=\"150\"><img src=\"img/chunjo.jpg\"></th></tr>";
                } else {
                echo 
"<th width=\"150\"><img src=\"img/jinno.jpg\"></th></tr>";
                }

}
echo 
"</table></center>";
echo 
"<br>";
?>

vielleicht kann mir das jemand machen.
F4m0uZStYle is offline  
Old 09/16/2011, 06:13   #4

 
•kяyteя•'s Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 2,876
Received Thanks: 982
PHP Code:
<?php 
echo "<center><table border=\"0\">
    <tr>
    <td width=\"30\"><b><center>Platz</center></b></td>
    <td width=\"200\"><b><center>Name</center></b></td>
    <td width=\"200\"><b><center>Leader</center></b></td>
    <td width=\"30\"><b><center>Level</center></b></td>
    <td width=\"150\"><b><center>Punkte</center></b></td>
    <td width=\"60\"><b><center>Gewonnen</center></b></td>
    <td width=\"60\"><b><center>Unentschieden</center></b></td>
    <td width=\"60\"><b><center>Verloren</center></b></td>
    <td width=\"60\"><b><center>Reich</center></b></td>
    </tr>"
;
 include 
'inc/dbsettings.php';
    
$db    "player";
    
mysql_connect($dbhost$dbuser$dbpw) OR
    die(
"ERROR: Connection failed. ".mysql_error());        
    
mysql_select_db($db) OR
    die(
"ERROR: DB allready open. ".mysql_error());
$sql "SELECT * FROM guild ORDER BY ladder_point desc, exp desc";
      
$i "0" ;
 
$ergebnis mysql_query($sql);
while(
$row mysql_fetch_object($ergebnis))
   {
   
$i $i ;
    
$leader $row->master;
   echo 
"
  <tr>
    <th width=\"40\"><font color=#FFFFFF>
$i</font></th>
    <th width=\"200\"><font color=#FFFFFF>
$row->name</a></font></th>
    <th width=\"60\"><font color=#FFFFFF>
$row->level</font></th>
    <th width=\"150\"><font color=#FFFFFF>
$row->ladder_point</font></th>
    <th width=\"150\"><font color=#FFFFFF>
$row->win</font></th>
    <th width=\"150\"><font color=#FFFFFF>
$row->draw</font></th>
    <th width=\"150\"><font color=#FFFFFF>
$row->loss</font></th>";
    
$reich mysql_query("SELECT empire from player_index where pid1 = '$leader' OR pid2 = '$leader' OR pid3 = '$leader' OR pid4 = '$leader'");
    
$reich2 mysql_fetch_object($reich);
    
$empire $reich2->empire;
    
$name mysql_query("SELECT name from player where id = '$leader'");
    if(
$empire == 1) {
                echo 
"<th width=\"150\"><img src=\"img/shinsoo.jpg\"></th></tr>";
                } elseif(
$empire == 2) {
                echo 
"<th width=\"150\"><img src=\"img/chunjo.jpg\"></th></tr>";
                } else {
                echo 
"<th width=\"150\"><img src=\"img/jinno.jpg\"></th></tr>";
                }

}
echo 
"</table></center>";
echo 
"<br>";
?>
Versuchs mal so...
Ich hoffe es funktioniert so...
Bin mir aber nicht sicher, bin da noch nicht ganz sooooooo
fit in PHP
•kяyteя• is offline  
Old 09/16/2011, 06:48   #5
 
F4m0uZStYle's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 284
Received Thanks: 87
wenn ich es so wie du es gepostet hast,ersetze wird mir beim leader nix angezeigt
F4m0uZStYle is offline  
Old 09/16/2011, 06:56   #6
 
elite*gold: 52
Join Date: Nov 2008
Posts: 773
Received Thanks: 432
PHP Code:
<?PHP
  $CPSeite 
50;
  
$markierteZeile=0;
  if(isset(
$_GET['p'])) {
    if(!
checkInt($_GET['p']) || !($_GET['p']>0)) $aSeite 1;
    else 
$aSeite $_GET['p'];
  }
  else { 
$aSeite 1; }
  
  if(isset(
$_POST['suche']) && $_POST['suche']=='suchen') {
    if(!empty(
$_POST['gilde'])) {
      
$sqlCmd="SELECT id,name,sp,master,level,exp,ladder_point, rang
      FROM (
      
        SELECT id,name,sp,master,level,exp,ladder_point, @num := @num +1 AS rang
        FROM (
        
          SELECT id,name,sp,master,level,exp,ladder_point, @num :=0
          FROM player.guild
          ORDER BY level DESC, sp DESC, exp DESC, win DESC, ladder_point DESC
          
        ) AS t1
        
      ) AS t2
       
      WHERE name = '"
.mysql_real_escape_string($_POST['gilde'])."' LIMIT 1";
      
$sqlQry=mysql_query($sqlCmd,$sqlServ);
      if(
mysql_num_rows($sqlQry)>0) {
      
        
$getRang mysql_fetch_object($sqlQry);
        
$aSeite ceil($getRang->rang/$CPSeite);
        
$markierteZeile $getRang->rang;
      }
      
    }
    
  }
  
  
$sqlCmd "SELECT COUNT(*) as summeChars  
  FROM player.guild 
  ORDER BY level DESC, sp DESC, exp DESC, win DESC, ladder_point DESC"
;
  
  
$sqlQry mysql_query($sqlCmd,$sqlServ);
  
  
$getSum mysql_fetch_object($sqlQry);
  
$cSeite calcPages($getSum->summeChars,$aSeite,$CPSeite);
  
?>
<h2>Gilden Rangliste</h2>
<p><center><a href="index.php?s=ranking_chars">Charakter Rangliste</a></center></p>
<form action="index.php?s=ranking_gilden" method="POST">
  <table>
    <tr>
      <th class="topLine">Suche</th>
      <td class="thell" style="text-align:center;"><input type="text" name="gilde" maxlength="20" size="20"/></td>
      <td class="tdunkel" style="text-align:center;"><input type="submit" name="suche" value="suchen" maxlength="20" size="20"/></td>
    </tr>
  </table>
</form>
<?PHP
  $maxRange 
5;
  
$maxStep 15;
  if((
$aSeite-$maxRange)>0$sStart $aSeite-$maxRange;
  else 
$sStart 1;
  if((
$aSeite+$maxRange)<=$cSeite[0]) $sEnde $aSeite+$maxRange;
  else 
$sEnde $cSeite[0];
  
  echo 
'<table>
  <tr>
  <td class="tdunkel">'
;
  if((
$aSeite-$maxStep)>0) echo '<a href="index.php?s=ranking_gilden&p='.($aSeite-$maxStep).'">'.($aSeite-$maxStep).'</a> &laquo;';
  else echo 
'<a href="index.php?s=ranking_gilden&p=1">1</a> &laquo;';
  echo
'</td>';
  
  for(
$i=$sStart;$i<=$sEnde;$i++) {
    
$sKlasse = ($i==$aSeite) ? "topLine" "thell";
    echo
'<td class="'.$sKlasse.'" style="text-align:center;">';
    echo
'<a href="index.php?s=ranking_gilden&p='.$i.'">'.$i.'</a>';
    echo
'</td>';
  }
  
  echo
'<td class="tdunkel" style="text-align:right;">';
  if((
$aSeite+$maxStep)<=$cSeite[0]) echo '&raquo; <a href="index.php?s=ranking_gilden&p='.($aSeite+$maxStep).'">'.($aSeite+$maxStep).'</a>';
  else echo 
'&raquo; <a href="index.php?s=ranking_gilden&p='.$cSeite[0].'">'.$cSeite[0].'</a>';
  echo
'</td>';
  echo
'</table>';
?>
<table>
<tr>
  <th class="topLine">Platz</th>
  <th class="topLine">Name</th>
  <th class="topLine">Leader</th>
  <th class="topLine">Level</th>
  <th class="topLine">SP</th>
  <th class="topLine">EXP</th>
  <th class="topLine">Punkte</th>
</tr>
<?PHP
  $sqlCmd 
"SELECT id,name,sp,master,level,exp,ladder_point 
  FROM player.guild 
  ORDER BY level DESC, sp DESC, exp DESC, win DESC, ladder_point DESC 
  LIMIT "
.$cSeite[1].",".$CPSeite;
  
$sqlQry mysql_query($sqlCmd,$sqlServ);
  
$x=$cSeite[1]+1;
  while(
$getPlayers mysql_fetch_object($sqlQry)) {
    
$zF = ($x%2==0) ? "thell" "tdunkel";
    if(
checkInt($markierteZeile) && $markierteZeile==$x) { $zF "tmarkiert"; }
    echo 
"<tr>";
    echo 
"<td class=\"$zF\">".$x."</td>";
    echo 
"<td class=\"$zF\"><a href='index.php?s=guild&guild=".$getPlayers->id."'>".$getPlayers->name."</a></td>";
    echo 
"<td class=\"$zF\"><a href='index.php?s=char&char=".$getPlayers->master."'>".charname($getPlayers->master)."</a></td>";
    echo 
"<td class=\"$zF\">".$getPlayers->level."</td>";
    echo 
"<td class=\"$zF\">".$getPlayers->sp."</td>";
    echo 
"<td class=\"$zF\">".$getPlayers->exp."</td>";
    echo 
"<td class=\"$zF\">".$getPlayers->ladder_point."</td>";
    echo 
"</tr>";
    
    
$x++;
    
  }
?>
</table>
iMaino is offline  
Old 09/16/2011, 07:46   #7
 
F4m0uZStYle's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 284
Received Thanks: 87
das klappt irgenwie bei mir nicht er liest mir nur den platz und den namen der gilde aus der rest liest er nicht aus
F4m0uZStYle is offline  
Old 09/16/2011, 14:00   #8
 
elite*gold: 52
Join Date: Nov 2008
Posts: 773
Received Thanks: 432
Probiers jetzt nochmal, habs ein bisschen bearbeitet - bei mir gehts. Das Script ist von Howan.
iMaino is offline  
Thanks
1 User
Old 09/17/2011, 06:53   #9
 
F4m0uZStYle's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 284
Received Thanks: 87
also wie gesagt wenn ich es nach deiner bearbeiteten gildenliste mache sieht es genau so bei mir aus.



So,okay das mit dem auslesen kann ich hin bekommen aber dann wird wd nur beim leader die ID angezeigt und nicht der name.

Denke irgenwas stimmt nicht ganz mit der Leadernamen zeile.

Eventuel könnt sich ja wer dran versuchen
F4m0uZStYle is offline  
Reply




All times are GMT +1. The time now is 23:13.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.