Już wiem jak robić metodą GET, ale chciałbym aby wszystkie informacje były wykorzystywane na innej stronie.
Oto moje 2 skrypty:
detal.php (ten plik ma wywietlać informacje odnośnie serwerów metodą $_GET, pobierając nr serwerów z bazy danych)
CODE
mysql_connect('', '', '') or
die (' Niepoprawne połączenie z bazą danych ');
mysql_select_db('otslista') or die (' Zła baza danych ');
$wynik = mysql_query ("SELECT * FROM `lista`;");
while ($rekord = mysql_fetch_assoc($wynik)) {
$nr = $rekord['nr'];
$name = $rekord['name'];
$host = $rekord['host'];
$port = $rekord['port'];
$ver = $rekord['ver'];
$exp = $rekord['exp'];
$type = $rekord['type'];
}
$w = mysql_query ("SELECT nr FROM `lista`;");
while($wiersz=mysql_fetch_array($w, MYSQL_NUM)) {
if($_GET['nr']=='$wiersz[0]') {
echo 'tu ma byc tresc strony';
} else {
echo 'nie ma ots w bazie danych';
}
}
mysql_close();
?>
die (' Niepoprawne połączenie z bazą danych ');
mysql_select_db('otslista') or die (' Zła baza danych ');
$wynik = mysql_query ("SELECT * FROM `lista`;");
while ($rekord = mysql_fetch_assoc($wynik)) {
$nr = $rekord['nr'];
$name = $rekord['name'];
$host = $rekord['host'];
$port = $rekord['port'];
$ver = $rekord['ver'];
$exp = $rekord['exp'];
$type = $rekord['type'];
}
$w = mysql_query ("SELECT nr FROM `lista`;");
while($wiersz=mysql_fetch_array($w, MYSQL_NUM)) {
if($_GET['nr']=='$wiersz[0]') {
echo 'tu ma byc tresc strony';
} else {
echo 'nie ma ots w bazie danych';
}
}
mysql_close();
?>
A oto cały skrypt, gdzie jest adres do detal.php, aby tam przekierować z ustawionym już numerem.
CODE
mysql_connect('', '', '') or
die (' Niepoprawne połączenie z bazą danych ');
mysql_select_db('otslista') or die (' Zła baza danych ');
$wynik = mysql_query ("SELECT * FROM `lista`;");
print "";
print " <FONT face="mortis" size="2">Nazwa <FONT face="mortis" size="2"> IP <FONT face="mortis" size="2"> Port <FONT face="mortis" size="2"> Gracze <FONT face="mortis" size="2"> Uptime ";
print " <FONT face="mortis" size="2"> Klient <FONT face="mortis" size="2"> Exp <FONT face="mortis" size="2"> Typ ";
print "\n";
while ($rekord = mysql_fetch_assoc($wynik)) {
$nr = $rekord['nr'];
$name = $rekord['name'];
$host = $rekord['host'];
$port = $rekord['port'];
$ver = $rekord['ver'];
$exp = $rekord['exp'];
$type = $rekord['type'];
$ip_serwera = $host;
$port_serwera = $port;
$info = chr(6).chr(0).chr(255).chr(255).'info';
$sock = @fsockopen($ip_serwera, $port_serwera, $errno, $errstr, 1);
if ($sock)
{
fwrite($sock, $info);
$data='';
while (!feof($sock))
$data .= fgets($sock, 1024);
fclose($sock);
preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);
preg_match('/uptime="(\d+)"/', $data, $matches);
$h = floor($matches[1] / 3600);
$m = floor(($matches[1] - $h*3600) / 60);
preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);
print "";
echo "<FONT face="Papyrus" size="2"><A href="\"detal.php?nr=$nr\"">$name";
print " <FONT face="Papyrus" size="2"> $host <FONT face="Papyrus" size="2"> $port <FONT face="Papyrus" size="2"> $matches[1] / $matches[2] <FONT face="Papyrus" size="2"> $h godzin $m minut ";
print " <FONT face="Papyrus" size="2"> $ver <FONT face="Papyrus" size="2"> $exp <FONT face="Papyrus" size="2"> $type ";
print "";
}
else
print "";
}
print '';
mysql_close();
?>
die (' Niepoprawne połączenie z bazą danych ');
mysql_select_db('otslista') or die (' Zła baza danych ');
$wynik = mysql_query ("SELECT * FROM `lista`;");
print "";
print " <FONT face="mortis" size="2">Nazwa <FONT face="mortis" size="2"> IP <FONT face="mortis" size="2"> Port <FONT face="mortis" size="2"> Gracze <FONT face="mortis" size="2"> Uptime ";
print " <FONT face="mortis" size="2"> Klient <FONT face="mortis" size="2"> Exp <FONT face="mortis" size="2"> Typ ";
print "\n";
while ($rekord = mysql_fetch_assoc($wynik)) {
$nr = $rekord['nr'];
$name = $rekord['name'];
$host = $rekord['host'];
$port = $rekord['port'];
$ver = $rekord['ver'];
$exp = $rekord['exp'];
$type = $rekord['type'];
$ip_serwera = $host;
$port_serwera = $port;
$info = chr(6).chr(0).chr(255).chr(255).'info';
$sock = @fsockopen($ip_serwera, $port_serwera, $errno, $errstr, 1);
if ($sock)
{
fwrite($sock, $info);
$data='';
while (!feof($sock))
$data .= fgets($sock, 1024);
fclose($sock);
preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);
preg_match('/uptime="(\d+)"/', $data, $matches);
$h = floor($matches[1] / 3600);
$m = floor(($matches[1] - $h*3600) / 60);
preg_match('/players online="(\d+)" max="(\d+)" peak="(\d+)"/', $data, $matches);
print "";
echo "<FONT face="Papyrus" size="2"><A href="\"detal.php?nr=$nr\"">$name";
print " <FONT face="Papyrus" size="2"> $host <FONT face="Papyrus" size="2"> $port <FONT face="Papyrus" size="2"> $matches[1] / $matches[2] <FONT face="Papyrus" size="2"> $h godzin $m minut ";
print " <FONT face="Papyrus" size="2"> $ver <FONT face="Papyrus" size="2"> $exp <FONT face="Papyrus" size="2"> $type ";
print "";
}
else
print "";
}
print '';
mysql_close();
?>
Prosiłbym o pomoc, chodzi o to, żeby wszystkie nr z tablei były akceptowane przez skrypt detal