Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 12:37

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

Advertisement



Problem mit PHP und MySQL

Discussion on Problem mit PHP und MySQL within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
Phillor's Avatar
 
elite*gold: 1
Join Date: Sep 2009
Posts: 462
Received Thanks: 125
Problem mit PHP und MySQL

Hallo elitepvpers!
Folgendes:
Ich habe eine Tabelle in der jeder User einzeln eingetragen ist.
Jeder hat auch eine zufällige Nummer zugewiesen bekommen.
Ich möchte nun, dass die Person mit der Nummer 1 und die mit der Nummer 2, also die Namen beider Personen jeweils in eine Variable gepackt wird.
Mein Problem ist nun, dass ich ja nicht immer weiß wie viele User gerade registriert sind. Also müsste ich eine Schleife benutzen um die ganzen Paare zu bilden.
Die Paare sollen in diesem Prinzip gebildet werden:
1+2 = 1.Paar
3+4 = 2.Paar
5+6 = 3.Paar
usw. ...

Ich habe mir dazu nun auch schon einige Gedanken gemacht, doch ich weiß leider nicht wie ich das realisieren kann.
Ich hoffe jemand kann mir helfen.

Danke schonmal im voraus.

lg
Phillor
Phillor is offline  
Old 04/30/2012, 20:37   #2
 
Project Rivalry's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 1,674
Received Thanks: 229
zwei schleifen ...

Quote:
for (i=0 ; i<(gesamt.user/2; i++){
for (z=0; z<2;z++){
$i.Paar =( i+1 )+ (i+2)
}


}
so irgendwie^^ bin das jetzt nur schnell gedanklich durchgegangen
Project Rivalry is offline  
Old 04/30/2012, 20:51   #3
 
Phillor's Avatar
 
elite*gold: 1
Join Date: Sep 2009
Posts: 462
Received Thanks: 125
Ich kann das nicht ganz nachvollziehen ehrlich gesagt.

i ist gleich 0. Damit die erste Schleife gestartet wird muss i kleiner als Die gesamte Anzahl an User geteilt durch 2 sein. und pro Schleifendurchlauf wird auf die variable i eins draufgerechnet.
Das verstehe ich irgendwie nicht.
Sorry aber ich stehe im Moment irgendwie total aufm Schlauch.
Phillor is offline  
Old 04/30/2012, 21:32   #4

 
マルコ's Avatar
 
elite*gold: 1329
Join Date: Jun 2009
Posts: 1,873
Received Thanks: 960
Das ganze ist einfach. Du gehst in einer Schleife alle Einträge geordnet nach der Nummer durch. Dabei machst du eine Variable, die nur jedes 2. Mal hochgezählt wird.

Beispiel:

Code:
function returnUserArray($host,$user,$pass,$database)
{
  $connection = mysql_connect($host,$user,$pass,true);
  mysql_select_db($database, $connection);
  $r = mysql_query("SELECT `name` FROM $database.hp_users ORDER BY `ID`",$connection);
  $i = 0;
  $c = 0;
  $return = false;
  while($row = mysql_fetch_assoc($r))
  {
    $return[$i][$c] = $row['name'];
    if($c == 1)
    {
      $c = 0;
      $i++;
    }
    else
      $c++;
  }
  mysql_close($connection);
  return $return;
}
Dann hast du ein Array mit Paar-Arrays.


Btw, das ist ungetestet ;P
マルコ is offline  
Thanks
1 User
Old 04/30/2012, 21:46   #5
 
Phillor's Avatar
 
elite*gold: 1
Join Date: Sep 2009
Posts: 462
Received Thanks: 125
also wären dann in $return die ganze Paare als Arrays gespeichert?
Phillor is offline  
Reply


Similar Threads Similar Threads
Problem with MySQL
04/30/2012 - CO2 Private Server - 3 Replies
Hi. I started to try to change the NewestCOServer database to MySQL. i'm using the MySQLhandler.dll that come with the 5355 Hellmoth Source, i think it is the same that used Elite Co-Emu. but i have a problem when using the INSERT method to create a character, it doesn't insert nothing :c, but i can insert data in other tables, that confused me. i have this in program.cs to begin the connection MySqlHandler.MySqlArgument arg = new MySqlHandler.MySqlArgument(); ...
[PROBLEM]:[Root]:Mysql:[...]/tmp/mysql.sock
10/22/2011 - Metin2 Private Server - 3 Replies
Hallo Community habe jetzt seit ein Paar Tagen einen Fehler Namens: failed, retrying in 5 secondsmysql_real_connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Screen: http://img809.imageshack.us/img809/9805/helpg.png
Help pls problem in MySql
08/31/2011 - EO PServer Hosting - 13 Replies
http://www6.0zz0.com/2011/06/07/09/555350516.jpg this problem in windows server 2008 any know how fix it pls tell me thx no any need help me ?
Mysql Problem
05/26/2010 - Metin2 Private Server - 0 Replies
Hallo eine frage was kann man dagegen machen das der mysql server nicht immer down fährt login is nun behoben aber nun schaltet mysql immer down das war schon seit anfang an so ??? MFG
MySql-Problem
05/22/2010 - Metin2 Private Server - 0 Replies
Hallo Seit kurzem habe ich bei meinem P-Server mehrere Probleme. Erst kam immer Connection refused, die DB "item_attr" ist gecrashed, immer wenn ich sie öffnen wollte, kam ne Meldung, 29-File./item_attr/ can't found oder so. Jetzt kann ich nichtmal mehr mit MySql verbinden. Bitte brauche Hilfe! Kriegt auch nen dickes THX:(:(:(:(:(:(



All times are GMT +1. The time now is 12:37.


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.