Jeg har nu haft tid til at kigge på den op og nedryknings funktion, men jeg har lidt problemer med at få det til at virke, er der nogen der kan fortælle mig hvad det er jeg har overset/gjort galt?
Det er sådan at de informationer som skal skrives ud på siden står i databasen army, under army er der så nogle forskellige kategorier som så bliver skrevet forskelligt ud på siden, under hver af de kategorier skal der være muligheden for at flytte op og ned på de informationer man har under hver kategori.
Koden er:
<!-- code sort start -->
<?php
require_once("../connect.php");
if(is_numeric($_GET['id']) && !empty($_GET['sort']))
{
$currentSort = 0;
$currentID = mysql_real_escape_string($_GET['id']);
$moveSort = 0;
$moveID = 0;
$query = mysql_query("SELECT sort FROM army WHERE id = " . $currentID . " LIMIT 1");
if(mysql_num_rows($query)>0)
{
$currentSort = mysql_result($query,0);
}
switch($_GET['sort'])
{
case "op":
$query = mysql_query("SELECT id, sort FROM army WHERE sort < ".$currentSort." ORDER BY sort DESC LIMIT 1");
break;
case "ned":
$query = mysql_query("SELECT id, sort FROM army WHERE sort > ".$currentSort." ORDER BY sort ASC LIMIT 1");
break;
default:
$moveSort = 0;
$moveID = 0;
}
if(mysql_num_rows($query)>0)
{
$row = mysql_fetch_assoc($query);
$moveID = $row['id'];
$moveSort = $row['sort'];
}
if($moveSort > 0)
{
$query = mysql_query("UPDATE army SET sort = ".$moveSort." WHERE id = ".$currentID." LIMIT 1");
$query = mysql_query("UPDATE army SET sort = ".$currentSort." WHERE id = ".$moveID." LIMIT 1");
}
}
?>
<!-- code sort finish -->
<center><img src="../../Images/Edit_WH40KTyranid.gif" /></center>
<br />
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td>
<?php
include "../bbcode.php";
include "../buttons.js";
?>
<?php
include '../connect.php';
if( isset( $_GET['id'] ) )
$id = $_GET['id'];
else
$id = null;
if( $id !== null ) {
// Hent først data ud
$resultat = mysql_query("select * FROM army WHERE id = '$id'");
// Kør så igennem for hver række
$raekke = mysql_fetch_array($resultat);
if( $raekke == null )
die("Fandt ikke rækken");
extract($raekke);
?>
<img src="../../Images/skull.gif" width="19" height="28" /><a href="#HQ" class="overskrift">HQ</a> <img src="../../Images/skull.gif" width="19" height="28" /><a href="#Elite" class="overskrift">Elites</a> <img src="../../Images/skull.gif" width="19" height="28" /><a href="#Troops" class="overskrift">Troops</a> <img src="../../Images/skull.gif" width="19" height="28" /><a href="#FastAtt" class="overskrift">Fast Attack</a> <img src="../../Images/skull.gif" width="19" height="28" /><a href="#Heavy" class="overskrift">Heavy Support</a><br>
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<tr><td>
<center>
<div id="HQ">
<img src="../../Images/skullwingsUNIT.jpg" />
</div>
<div class="overskriftminuscenter">HQ</div>
</center>
</td></tr>
<tr><td>
<!--WHLord Start -->
<table>
<?php
$query = mysql_query("SELECT * FROM army WHERE unit_race='WH40KTyranid' AND unit_section='WH40KHQ' ORDER BY sort");
if(mysql_num_rows($query)>0)
{
while($row = mysql_fetch_assoc($query)){
$unit_navn = stripslashes($row[unit_navn]);
$unit_text = stripslashes($row[unit_text]);
$unit_positiv = stripslashes($row[unit_positiv]);
$unit_negativ = stripslashes($row[unit_negativ]);
$newtext = nl2br($newtext);
$thumbnail = $row["thumbnail"];
$originalpic = $row["originalpic"];
$dato = $row["dato"];
?>
<tr align="left" valign="middle">
<td colspan="2"><font class="dato"><?php echo "$dato" ?></font><br /><font class="unithead"><?php $htmlunit_navn = bbcode($unit_navn); echo "$htmlunit_navn" ?></font></td>
</tr>
<tr>
<td width="130" rowspan="4" align="left" valign="top"><a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="../addunit/images/<?php echo "$thumbnail" ?>" border="0"></a><br />
<a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="
http://www.barricade.dk/Images/pushpic.gif" width="41" height="9" border="0"/></a></td>
<td width="605"><font class="text"><?php $htmlunit_text = bbcode($unit_text); echo "$htmlunit_text" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Positiv</b></font>
<br>
<font class="text"><?php $htmlunit_positiv = bbcode($unit_positiv); echo "$htmlunit_positiv" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Negativ</b></font>
<br>
<font class="text"><?php $htmlunit_negativ = bbcode($unit_negativ); echo "$htmlunit_negativ" ?></font>
<p></td>
</tr>
<tr>
<td align="right" valign="middle"><a href="<?php .$_SERVER['PHP_SELF'].?id=.$row['id'].&sort=op ?>">OP</a> | <a href="<?php .$_SERVER['PHP_SELF'].?id=.$row['id'].&sort=ned ?>">NED</a></td>
<?php
}
}
?>
</tr>
<tr>
</table>
<!--WHLord Slut -->
</td></tr>
<tr><td>
<center>
<div id="Elite">
<img src="../../Images/skullwingsUNIT.jpg" />
</div>
<div class="overskriftminuscenter">Elites</div>
</center>
</td></tr>
<tr><td>
<!--WHHeroes Start -->
<table>
<?
$query = mysql_query("SELECT * FROM army WHERE unit_race='WH40KTyranid' AND unit_section='WH40KElite'") or die("Der er sket en fejl. Fejlnr. ".mysql_errno());
while ($row = mysql_fetch_array($query)) {
$unit_navn = stripslashes($row[unit_navn]);
$unit_text = stripslashes($row[unit_text]);
$unit_positiv = stripslashes($row[unit_positiv]);
$unit_negativ = stripslashes($row[unit_negativ]);
$newtext = nl2br($newtext);
$thumbnail = $row["thumbnail"];
$originalpic = $row["originalpic"];
$dato = $row["dato"];
?>
<tr align="left" valign="middle">
<td colspan="2"><font class="dato"><?php echo "$dato" ?></font><br /><font class="unithead"><?php $htmlunit_navn = bbcode($unit_navn); echo "$htmlunit_navn" ?></font></td>
</tr>
<tr>
<td width="130" rowspan="3" align="left" valign="top"><a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="../addunit/images/<?php echo "$thumbnail" ?>" border="0"></a><br />
<a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="
http://www.barricade.dk/Images/pushpic.gif" width="41" height="9" border="0"/></a></td>
<td width="605"><font class="text"><?php $htmlunit_text = bbcode($unit_text); echo "$htmlunit_text" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Positiv</b></font>
<br>
<font class="text"><?php $htmlunit_positiv = bbcode($unit_positiv); echo "$htmlunit_positiv" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Negativ</b></font>
<br>
<font class="text"><?php $htmlunit_negativ = bbcode($unit_negativ); echo "$htmlunit_negativ" ?></font>
<p>
</td>
</tr>
<tr>
<?php
}
?>
</table>
<!--WHHeroes Slut -->
</td></tr>
<tr><td>
<center>
<div id="Troops">
<img src="../../Images/skullwingsUNIT.jpg" />
</div>
<div class="overskriftminuscenter">Troops</div>
</center>
</td></tr>
<tr><td>
<!--WHCoreUnits Start -->
<table>
<?
$query = mysql_query("SELECT * FROM army WHERE unit_race='WH40KTyranid' AND unit_section='WH40KTroops'") or die("Der er sket en fejl. Fejlnr. ".mysql_errno());
while ($row = mysql_fetch_array($query)) {
$unit_navn = stripslashes($row[unit_navn]);
$unit_text = stripslashes($row[unit_text]);
$unit_positiv = stripslashes($row[unit_positiv]);
$unit_negativ = stripslashes($row[unit_negativ]);
$newtext = nl2br($newtext);
$thumbnail = $row["thumbnail"];
$originalpic = $row["originalpic"];
$dato = $row["dato"];
?>
<tr align="left" valign="middle">
<td colspan="2"><font class="dato"><?php echo "$dato" ?></font><br /><font class="unithead"><?php $htmlunit_navn = bbcode($unit_navn); echo "$htmlunit_navn" ?></font></td>
</tr>
<tr>
<td width="130" rowspan="3" align="left" valign="top"><a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="../addunit/images/<?php echo "$thumbnail" ?>" border="0"></a><br />
<a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="
http://www.barricade.dk/Images/pushpic.gif" width="41" height="9" border="0"/></a></td>
<td width="605"><font class="text"><?php $htmlunit_text = bbcode($unit_text); echo "$htmlunit_text" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Positiv</b></font>
<br>
<font class="text"><?php $htmlunit_positiv = bbcode($unit_positiv); echo "$htmlunit_positiv" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Negativ</b></font>
<br>
<font class="text"><?php $htmlunit_negativ = bbcode($unit_negativ); echo "$htmlunit_negativ" ?></font>
<p>
</td>
</tr>
<tr>
<?php
}
?>
</table>
<!--WHCoreUnits Slut -->
</td></tr>
<tr><td>
<center>
<div id="FastAtt">
<img src="../../Images/skullwingsUNIT.jpg" />
</div>
<div class="overskriftminuscenter">Fast Attack</div>
</center>
</td></tr>
<tr><td>
<!--WHSpecialUnits Start -->
<table>
<?
$query = mysql_query("SELECT * FROM army WHERE unit_race='WH40KTyranid' AND unit_section='WH40KFastAtt'") or die("Der er sket en fejl. Fejlnr. ".mysql_errno());
while ($row = mysql_fetch_array($query)) {
$unit_navn = stripslashes($row[unit_navn]);
$unit_text = stripslashes($row[unit_text]);
$unit_positiv = stripslashes($row[unit_positiv]);
$unit_negativ = stripslashes($row[unit_negativ]);
$newtext = nl2br($newtext);
$thumbnail = $row["thumbnail"];
$originalpic = $row["originalpic"];
$dato = $row["dato"];
?>
<tr align="left" valign="middle">
<td colspan="2"><font class="dato"><?php echo "$dato" ?></font><br /><font class="unithead"><?php $htmlunit_navn = bbcode($unit_navn); echo "$htmlunit_navn" ?></font></td>
</tr>
<tr>
<td width="130" rowspan="3" align="left" valign="top"><a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="../addunit/images/<?php echo "$thumbnail" ?>" border="0"></a><br />
<a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="
http://www.barricade.dk/Images/pushpic.gif" width="41" height="9" border="0"/></a></td>
<td width="605"><font class="text"><?php $htmlunit_text = bbcode($unit_text); echo "$htmlunit_text" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Positiv</b></font>
<br>
<font class="text"><?php $htmlunit_positiv = bbcode($unit_positiv); echo "$htmlunit_positiv" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Negativ</b></font>
<br>
<font class="text"><?php $htmlunit_negativ = bbcode($unit_negativ); echo "$htmlunit_negativ" ?></font>
<p>
</td>
</tr>
<tr>
<?php
}
?>
</table>
<!--WHSpecialUnits Slut -->
</td></tr>
<tr><td>
<center>
<div id="Heavy">
<img src="../../Images/skullwingsUNIT.jpg" />
</div>
<div class="overskriftminuscenter">Heavy Support</div>
</center>
</td></tr>
<tr><td>
<!--WHSpecialUnits Start -->
<table>
<?
$query = mysql_query("SELECT * FROM army WHERE unit_race='WH40KTyranid' AND unit_section='WH40KHeavy'") or die("Der er sket en fejl. Fejlnr. ".mysql_errno());
while ($row = mysql_fetch_array($query)) {
$unit_navn = stripslashes($row[unit_navn]);
$unit_text = stripslashes($row[unit_text]);
$unit_positiv = stripslashes($row[unit_positiv]);
$unit_negativ = stripslashes($row[unit_negativ]);
$newtext = nl2br($newtext);
$thumbnail = $row["thumbnail"];
$originalpic = $row["originalpic"];
$dato = $row["dato"];
?>
<tr align="left" valign="middle">
<td colspan="2"><font class="dato"><?php echo "$dato" ?></font><br /><font class="unithead"><?php $htmlunit_navn = bbcode($unit_navn); echo "$htmlunit_navn" ?></font></td>
</tr>
<tr>
<td width="130" rowspan="3" align="left" valign="top"><a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="../addunit/images/<?php echo "$thumbnail" ?>" border="0"></a><br />
<a href="../addunit/images/<?php echo "$originalpic" ?>" target="_blank"><img src="
http://www.barricade.dk/Images/pushpic.gif" width="41" height="9" border="0"/></a></td>
<td width="605"><font class="text"><?php $htmlunit_text = bbcode($unit_text); echo "$htmlunit_text" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Positiv</b></font>
<br>
<font class="text"><?php $htmlunit_positiv = bbcode($unit_positiv); echo "$htmlunit_positiv" ?></font></td>
</tr>
<tr>
<td>
<font class="text"><b>Negativ</b></font>
<br>
<font class="text"><?php $htmlunit_negativ = bbcode($unit_negativ); echo "$htmlunit_negativ" ?></font>
<p>
</td>
</tr>
<tr>
<?php
}
?>
</table>
<!--WHSpecialUnits Slut -->
</td></tr>
</table>