Работещ код + грешка.

z7c

Registered
Здравейте ето код който страницира и извежда резултати от базата данни.. без да показва резултатите обаче... има някакъв проблем..

<?php

include("../dbc.php");

$page = (int) $_GET['page'];

$max= "2";

$end = $page+$max;
if (!isset($_GET['player'])) {
$mysql = mysql_query("SELECT * FROM `chess` limit $page,$end")or die(mysql_error());
while ($players = mysql_fetch_array($mysql)) {
echo "<a href=\"?player=$players[player]\"> $players[player] </a> <br />";
}
echo "Общо ".mysql_num_rows($mysql)." играча.";
$next = $end+1;

$prev = $page-10;

echo "<a href=\"index.php?page=".$next."\">следваща</a>";
echo "<a href=\"index.php?page=".$prev."\">предишна</a>";
}
else {
if (!empty($_GET['player'])) {
$prt = mysql_result(mysql_query("SELECT game FROM `chess` WHERE player='".htmlspecialchars(addslashes($_GET['player']))."'"),0)or die(mysql_error());
echo "Партия: ".$prt." <br />";
}
}
?>


дано някой успее да помогне..
 
Базата данни да не е празна. Пробвай така-->
Код:
<?php

include("../dbc.php");

$page = (int) $_GET['page'];

$max= "2";

$end = $page+$max;
if (!isset($_GET['player'])) {
$mysql = mysql_query("SELECT * FROM `chess` limit $page,$end") or die(mysql_error());
while ($players = mysql_fetch_array($mysql)) {
echo "<a href=\"?player=$players['player']\"> $players['player'] </a> <br />";
}
echo "Общо ".mysql_num_rows($mysql)." играча.";
$next = $end+1;

$prev = $page-10;

echo "<a href=\"index.php?page=".$next."\">следваща</a>";
echo "<a href=\"index.php?page=".$prev."\">предишна</a>";
}
else {
if (!empty($_GET['player'])) {
$prt = mysql_result(mysql_query("SELECT game FROM `chess` WHERE player='".htmlspecialchars(addslashes($_GET['player']))."'"),0)or die(mysql_error());
echo "Партия: ".$prt." <br />";
}
}
?>
 
отново не става...
а базата данни не е изобщо празна.. има точно 6 записки.. и попринцип кода когато е само за извеждане ги извежда.. но + този за странициране .. не става.. и не ги извежда , но не дава и грешка
 
Zion каза:
Базата данни да не е празна. Пробвай така-->
Код:
<?php

include("../dbc.php");

$page = (int) $_GET['page'];

$max= "2";

$end = $page+$max;
if (!isset($_GET['player'])) {
$mysql = mysql_query("SELECT * FROM `chess` limit $page,$end") or die(mysql_error());
while ($players = mysql_fetch_array($mysql)) {
echo "<a href="?player=$players['player']"> $players['player'] </a> <br />";
}
echo "Общо ".mysql_num_rows($mysql)." играча.";
$next = $end+1;

$prev = $page-10;

echo "<a href="index.php?page=".$next."">следваща</a>";
echo "<a href="index.php?page=".$prev."">предишна</a>";
}
else {
if (!empty($_GET['player'])) {
$prt = mysql_result(mysql_query("SELECT game FROM `chess` WHERE player='".htmlspecialchars(addslashes($_GET['player']))."'"),0)or die(mysql_error());
echo "Партия: ".$prt." <br />";
}
}
?>
Ето тук можеш да видиш как работи кода + странициране http://www.php.pirin2006.com/2.php
и ето тук можеш да видиш кода без странициране че си работи:
http://www.php.pirin2006.com/1.php
 
Код:
 <?php

include("../dbc.php");

$page = (int) $_GET['page'];

$max= "2";

$end = $page+$max;

if (!isset($_GET['player'])) {
$mysql = mysql_query("SELECT * FROM `chess` limit $page,$end")or die(mysql_error());
while ($players = mysql_fetch_array($mysql)) {
$player = ($players['player']);
echo "<a href=\"?player=$player\">$player</a> <br />";
}
echo "Общо ".mysql_num_rows($mysql)." играча.";
$next = $end+1;

$prev = $page-10;

echo "<a href=\"index.php?page=".$next."\">следваща</a>";
echo "<a href=\"index.php?page=".$prev."\">предишна</a>";
}
else {
if (!empty($_GET['player'])) {
$prt = mysql_result(mysql_query("SELECT game FROM `chess` WHERE player='".htmlspecialchars(addslashes($_GET['player']))."'"),0)or die(mysql_error());
echo "Партия: ".$prt." <br />";
}
}
?>


Taка ?
 
0u7 каза:
Код:
 <?php

include("../dbc.php");

$page = (int) $_GET['page'];

$max= "2";

$end = $page+$max;

if (!isset($_GET['player'])) {
$mysql = mysql_query("SELECT * FROM `chess` limit $page,$end")or die(mysql_error());
while ($players = mysql_fetch_array($mysql)) {
$player = ($players['player']);
echo "<a href="?player=$player">$player</a> <br />";
}
echo "Общо ".mysql_num_rows($mysql)." играча.";
$next = $end+1;

$prev = $page-10;

echo "<a href="index.php?page=".$next."">следваща</a>";
echo "<a href="index.php?page=".$prev."">предишна</a>";
}
else {
if (!empty($_GET['player'])) {
$prt = mysql_result(mysql_query("SELECT game FROM `chess` WHERE player='".htmlspecialchars(addslashes($_GET['player']))."'"),0)or die(mysql_error());
echo "Партия: ".$prt." <br />";
}
}
?>


Taка ?

http://php.pirin2006.com/2.php
 
Код:
<?php

include("../dbc.php");

$page = (int) $_GET['page'];

$max= "2";

$end = $page+$max;

if (!isset($_GET['player'])) {
$mysql = mysql_query("SELECT * FROM `chess`order by `chess` DESC limit $page,$end")or die(mysql_error());
while ($players = mysql_fetch_array($mysql)) {
$player = ($players['player']);
echo "<a href=\"?player=$player\">$player</a> <br />";
}
echo "Общо ".mysql_num_rows($mysql)." играча.";
$next = $end+1;

$prev = $page-10;

echo "<a href=\"index.php?page=".$next."\">следваща</a>";
echo "<a href=\"index.php?page=".$prev."\">предишна</a>";
}
else {
if (!empty($_GET['player'])) {
$prt = mysql_result(mysql_query("SELECT game FROM `chess` WHERE player='".htmlspecialchars(addslashes($_GET['player']))."'"),0)or die(mysql_error());
echo "Партия: ".$prt." <br />";
}
}
?>



Ако нестане дай кода на тази страница http://www.php.pirin2006.com/1.php
да видя нещо..
 
След като ми прати кода на лс


пробвай така



Код:
<?php

include("dbc.php");

$page = (int) $_GET['page'];

$max= "2";

$end = $page+$max;

if (!isset($_GET['player'])) {
$mysql = mysql_query("SELECT * FROM `chess`order by `chess` DESC limit $page,$end")or die(mysql_error());
while ($players = mysql_fetch_array($mysql)) {
$player = ($players['player']);
echo "<a href=\"?player=$player\">$player</a> <br />";
}
echo "Общо ".mysql_num_rows($mysql)." играча.";
$next = $end+1;

$prev = $page-10;

echo "<a href=\"index.php?page=".$next."\">следваща</a>";
echo "<a href=\"index.php?page=".$prev."\">предишна</a>";
}
else {
if (!empty($_GET['player'])) {
$prt = mysql_result(mysql_query("SELECT game FROM `chess` WHERE player='".htmlspecialchars(addslashes($_GET['player']))."'"),0)or die(mysql_error());
echo "Партия: ".$prt." <br />";
}
}
?>
 

Горе