unplugged_web Posted August 2, 2012 Share Posted August 2, 2012 (edited) I'm not sure why this isn't working. I have a table of entries, but I'd like to change the running order of the entries. I've created a field called 'priority' and I want the people in the back end to change the order of the entries themselves. So for example, if they move one entry up then the one above will automatically move down. I'm not getting any errors at all, just a blank page.The code I've written is: <?php$id = $_GET['id'];$direction = $_GET['direction']; con = mysql_connect("hostname", "user", "password");if (!$con){die('Could not connect: ' . mysql_error());}mysql_select_db("table", $con); $sql = "SELECT priority FROM Reviews WHERE ID = $id";list($curpos) = mysql_fetch_array(mysql_query($sql) or die(mysql_error())); // Find new positionif ($direction > 0){// To be moved up$sql = "SELECT priority FROM Reviews WHERE priority < '$curpos' ORDER BY priority LIMIT 1";list($newpos) = mysql_fetch_array(mysql_query($sql) or die(mysql_error()));}else{// To be moved down$sql = "SELECT priority FROM Reviews WHERE priority > '$curpos' ORDER BY priority LIMIT 1";list($newpos) = mysql_fetch_array(mysql_query($sql) or die(mysql_error()));} if ($newpos){$sql = "UPDATE Reviews SET priority = $curpos WHERE priority = $newpos";mysql_query($sql) or die(mysql_error()); $sql = "UPDATE Reviews SET priority = $newpos WHERE ID = $id AND priority = $curpos";mysql_query($sql) or die(mysql_error()); if (!mysql_error() && mysql_affected_rows()) $msg = "Review moved"; }mysql_close($con);?> but this doesn't seem to do anything. I'd be grateful for any help. I have in working perfectly for another table in the same database, but even if I copy the code over and ust change the relevant fields it still doesn't work. The 'priority' field is set to not null and is an integer. Thanks for any help Edited August 2, 2012 by thehappyappy Link to comment Share on other sites More sharing options...
justsomeguy Posted August 2, 2012 Share Posted August 2, 2012 You can use a tool like this to check for syntax errors: http://www.piliapp.com/php-syntax-check/ If you're not seeing an error then your server isn't reporting them. Link to comment Share on other sites More sharing options...
unplugged_web Posted August 3, 2012 Author Share Posted August 3, 2012 You can use a tool like this to check for syntax errors: http://www.piliapp.c...p-syntax-check/ If you're not seeing an error then your server isn't reporting them.Thanks, I'll check out that link, the server was showing errors but I fixed those then it stopped showing them altogether. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now