Jeg har leget lidt med en anden php som jeg prøver at få til at hente info fra min database, men det går ikke skide godt...
Det er meningeningen at man skal kunne trykke på datoen som er id'et til databasen, derudover skal page, saeson, modstander vises sammen med delete og edit.
filterfunktionen virker heller ikke... jeg vil gerne have at man både kan sortere ved at trykke på overskrifterne samt kun se kampe for et hold(page) vha. dropdown vælgeren...
På forhånd tak for hjælpen:-)
koden ser således ud:
<?
include"../config.php";
include("header.php");
include("kampenav.php");
if(!empty($_GET[OrderBy]))
{
$OrderBy = "$_GET[OrderBy]";
}
else
{
$OrderBy = "Dato";
}
if(!empty($_GET[OrderType]))
{
$OrderType = "$_GET[OrderType]";
}
else
{
$OrderType = "Asc";
}
if(!empty($_GET[Type]))
{
$Filter .= "and `Type` = '$_GET[Type]'";
}
if(!empty($_GET[Start]))
{
$Start = $_GET[Start];
}
else
{
$Start = '0';
}
$ByPage = "25";
$qnav = "select * from `Kampe` where `Dato` != '0' $Filter order by `$OrderBy` $OrderType";
$rnav = mysql_query($qnav) or die(mysql_error());
$rows = mysql_num_rows($rnav);
if($rows > $ByPage)
{
$NextPrev = "<br><table align=center width=50%>";
$NextPrev .= "<td align=center><strong>Pages:</strong> | ";
$pages = ceil($rows/$ByPage);
for($i = 0; $i <= ($pages); $i++)
{
$PageStart = $ByPage*$i;
$i2 = $i + 1;
if($PageStart == $Start)
{
$links[] = " <strong>$i2</strong>\\n\\t ";
}
elseif($PageStart < $rows)
{
$links[] = " <a href=\\"kampe.php?Start=$PageStart&ByPage=$ByPage&Page=$_GET[Page]&Type=$_GET[Type]&OrderBy=$_GET[OrderBy]&OrderType=$_GET[OrderType]\\">$i2</a>\\n\\t ";
}
}
$links2 = implode(" | ", $links);
$NextPrev .= $links2;
$NextPrev .= "| </td>";
$NextPrev .= "</table><br>\\n";
}
$qData = "select * from `Kampe` where `Dato` != '0' $Filter order by `$OrderBy` $OrderType limit $Start, $ByPage";
$rData = mysql_query($qData) or die(mysql_error());
if(mysql_num_rows($rData) == '0')
{
echo "<br><center><b>No record found in database.</b></center>";
}
else
{
if($_GET[OrderBy] ==Type && $_GET[OrderType]==Asc)
{
$Type_Link = "<a href=\\"kampe.php?OrderBy=Type&Page=$_GET[Page]&OrderType=Desc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Type</a> <img src=\\"images/asc.png\\" alt=\\"asc\\">";
}
elseif($_GET[OrderBy] ==Type && $_GET[OrderType]==Desc)
{
$Type_Link = "<a href=\\"kampe.php?OrderBy=Type&Page=$_GET[Page]&OrderType=Asc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Type</a> <img src=\\"images/desc.png\\" alt=\\"desc\\">";
}
else
{
$Type_Link = "<a href=\\"kampe.php?OrderBy=Type&Page=$_GET[Page]&OrderType=Asc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Type</a>";
}
if($_GET[OrderBy] ==Name && $_GET[OrderType]==Asc)
{
$Name_Link = "<a href=\\"kampe.php?OrderBy=Name&Page=$_GET[Page]&OrderType=Desc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Name</a> <img src=\\"images/asc.png\\" alt=\\"asc\\">";
}
elseif($_GET[OrderBy] ==Name && $_GET[OrderType]==Desc)
{
$Name_Link = "<a href=\\"kampe.php?OrderBy=Name&Page=$_GET[Page]&OrderType=Asc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Name</a> <img src=\\"images/desc.png\\" alt=\\"desc\\">";
}
else
{
$Name_Link = "<a href=\\"kampe.php?OrderBy=Name&Page=$_GET[Page]&OrderType=Asc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Name</a>";
}
if($_GET[OrderBy] ==Picture && $_GET[OrderType]==Asc)
{
$Picture_Link = "<a href=\\"kampe.php?OrderBy=Picture&Page=$_GET[Page]&OrderType=Desc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Picture</a> <img src=\\"images/asc.png\\" alt=\\"asc\\">";
}
elseif($_GET[OrderBy] ==Picture && $_GET[OrderType]==Desc)
{
$Picture_Link = "<a href=\\"kampe.php?OrderBy=Picture&Page=$_GET[Page]&OrderType=Asc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Picture</a> <img src=\\"images/desc.png\\" alt=\\"desc\\">";
}
else
{
$Page_Link = "<a href=\\"kampe.php?OrderBy=Picture&Page=$_GET[Page]&OrderType=Asc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Page</a>";
}
if($_GET[OrderBy] ==Page && $_GET[OrderType]==Asc)
{
$Page_Link = "<a href=\\"kampe.php?OrderBy=Page&Page=$_GET[Page]&OrderType=Desc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Page</a> <img src=\\"images/asc.png\\" alt=\\"asc\\">";
}
elseif($_GET[OrderBy] ==Page && $_GET[OrderType]==Desc)
{
$Page_Link = "<a href=\\"kampe.php?OrderBy=Page&Page=$_GET[Page]&OrderType=Asc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Page</a> <img src=\\"images/desc.png\\" alt=\\"desc\\">";
}
else
{
$Page_Link = "<a href=\\"kampe.php?OrderBy=Page&Page=$_GET[Page]&OrderType=Asc&Type=$_GET[Type]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\" class=\\"topheading\\">Page</a>";
}
echo"
<select name=\\"PageFilter\\" onChange=\\"location=document.jump.PageFilter.options[document.jump.PageFilter.selectedIndex].value;\\" value=\\"GO\\">
<option selected>Sorter efter</option>
<option value=\\"kampe.php?Type=$_GET[Type]&OrderBy=$_GET[OrderBy]&OrderType=$_GET[OrderType]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\">All</option>
<option value=\\"kampe.php?Page=1&Type=$_GET[Type]&OrderBy=$_GET[OrderBy]&OrderType=$_GET[OrderType]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\">Serie 3</option>
<option value=\\"kampe.php?Page=2&Type=$_GET[Type]&OrderBy=$_GET[OrderBy]&OrderType=$_GET[OrderType]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\">Serie 6</option>
<option value=\\"kampe.php?Page=3&Type=$_GET[Type]&OrderBy=$_GET[OrderBy]&OrderType=$_GET[OrderType]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\">Veteran</option>
<option value=\\"kampe.php?Page=4&Type=$_GET[Type]&OrderBy=$_GET[OrderBy]&OrderType=$_GET[OrderType]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\">U-10</option>
<option value=\\"kampe.php?Page=5&Type=$_GET[Type]&OrderBy=$_GET[OrderBy]&OrderType=$_GET[OrderType]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\">U-8</option>
<option value=\\"kampe.php?Page=6&Type=$_GET[Type]&OrderBy=$_GET[OrderBy]&OrderType=$_GET[OrderType]&Start=$_GET[Start]&ByPage=$_GET[ByPage]\\">U-7</option>
</select>
";
echo"</form></div>";
if(!empty($_GET[Type]))
{
echo"<h2>Type: $_GET[Type]</h2>";
}
echo"
<form method=\\"POST\\" action=\\"deletekamp.php\\">
<table border=\\"0\\" width=\\"100%\\">
<tr class=tdblue>
<td width=\\"20%\\" style=\\"padding-left: 3\\">$Dato_Link</td>
<td width=\\"20%\\" style=\\"padding-left: 3\\">$Page_Link</td>
<td width=\\"10%\\" style=\\"padding-left: 3\\">$Season_Link</td>
<td width=\\"40%\\" style=\\"padding-left: 3\\">$Modstander_Link</td>
<td width=\\"8%\\"> Delete</td>
<td width=\\"8%\\"> Edit</td>
</tr>";
$n=1;
while($aData = mysql_fetch_array($rData))
{
if($aData[Page] == 1)
{
$PageTitle = "Serie 3";
}
elseif($aData[Page] == 2)
{
$PageTitle = "Serie 6";
}
elseif($aData[Page]=="3")
{
$PageTitle = "Veteran";
}
elseif($aData[Page] == 4)
{
$PageTitle = "U-10";
}
elseif($aData[Page] == 5)
{
$PageTitle = "U-8";
}
elseif($aData[Page] == 6)
{
$PageTitle = "U-7";
}
elseif($aData[Page] == 7)
{
$PageTitle = "Stoppede spillere";
}
if($col == White)
{
$col = "#CCCCCC";
}
else
{
$col = "White";
}
if(!empty($aData[Dato]))
{
$xy = @getimagesize("../profiles_files/$aData[Dato]");
$x = $xy[0];
$y = $xy[1];
$Image = "<a href=\\"detailprofiles.php?ProfileID=$aData[Dato]\\"><img border=\\"1\\" style=\\"border: 1px solid #000000\\" src=\\"../profiles_files/thumbs/$aData[Dato]\\" width=\\"150\\" height=\\"112\\"></a>";
}
else
{
$Image = "<a href=\\"detailprofiles.php?ProfileID=$aData[Dato]\\"><img border=\\"1\\" style=\\"border: 1px solid #B49C76\\" src=\\"../images/noimage.jpg\\" width=\\"150\\" height=\\"112\\"></a>";
}
echo"
<tr bgcolor=\\"$col\\">
<td width=\\"20%\\" style=\\"padding-left: 3\\" valign=\\"top\\">$aData[Dato]</td>
<td width=\\"20%\\" style=\\"padding-left: 3\\" valign=\\"top\\">$aPage[Page]</td>
<td width=\\"10%\\" style=\\"padding-left: 3\\" valign=\\"top\\">$aSaeson[Saeson]</td>
<td width=\\"40%\\" style=\\"padding-left: 3\\" valign=\\"top\\">$aData[Modstander]</td>
<td width=\\"8%\\" style=\\"padding-left: 3\\" valign=\\"top\\"><input type=\\"checkbox\\" name=\\"Delete[]\\" value=\\"$aData[Dato]\\"></td>
<td width=\\"8%\\" style=\\"padding-left: 3\\" valign=\\"top\\"><a href=\\"editkampe.php?ProfileID=$aData[Dato]\\"><img border=\\"0\\" src=\\"images/edit.jpg\\" width=\\"59\\" height=\\"17\\"></a>
</tr>";
$n++;
}
echo "</table><br>$NextPrev<br><input type=\\"submit\\" value=\\"Update Database\\" name=\\"B1\\"></form>";
}
include("footer.php");
?>
?>
Indlæg senest redigeret d. 12.12.2007 14:27 af Bruger #10467