function replaceMVOrder($ID, $NewPos) { $db = new PDO('sqlite:zahabe.db'); $pos1 = getMVByNumber($db, $NewPos - 1); $pos2 = getMVByNumber($db, $NewPos); $calcPos = $pos1["MVOrder"] + ($pos2["MVOrder"] - $pos1["MVOrder"]) / 2; if ($calcPos <= 1) { return FALSE; } try { $stmt = $db->prepare("UPDATE MinnsDu\r\n SET MVOrder=:MVOrder\r\n where ID = :id "); $stmt->bindParam(':MVOrder', $calcPos); $stmt->bindParam(':id', $ID); $stmt->execute(); } catch (PDOException $e) { return 'Exception : ' . $e->getMessage(); } $db = null; return true; }
*cnt = Return MV with ordered numbered specified *add = Adds a new MV *type > *=daily *=stories = Returns all *no parameters = Returns all MVs * *returns json format */ include 'functions.php'; $db = new PDO('sqlite:zahabe.db'); if (isset($_GET['id'])) { $rows = getMVByID($db, $_GET['id']); } else { if (isset($_GET['cnt'])) { $rows = getMVByNumber($db, $_GET['cnt']); } else { if (isset($_GET['add'])) { /*Not implemented*/ print "To be implemented"; } else { if (isset($_GET['type'])) { if ($_GET['type'] == "daily") { $rows = getDailyMV($db); } else { if ($_GET['type'] == "stories") { $rows = getAllStories($db); } } } else { $stmt = $db->prepare("SELECT Text, ID, Story, (select count(*) from MinnsDu b where a.id >= b.id) as cnt\n FROM MinnsDu a LEFT JOIN Stories ON a.ID = Stories.MVID ORDER BY ID asc");
ga('create', 'UA-63495608-1', 'auto'); ga('send', 'pageview'); </script> </head> <body> <div id="wrapper"> <a href="zahabe.php" id="rubrik"><h1>Minns vi den gången Zahabe...</h1></a> <?php if ($ID == '1') { print '...försökte rubba det fundament på vilket allt vilade?'; } else { if ($password == "iklabbe") { try { $db = new PDO('sqlite:zahabe.db'); $row2 = getMVByNumber($db, $ID); $MVID = $row2['ID']; if (empty($MVID)) { print '...gick vilse?'; } else { echo '<form action="editAction.php?id=' . $MVID . '" method="post" accept-charset="utf-8" autocomplete="off"> <div id="formbox"> <input type="integer" name="newPos" id="editPos" placeholder="#" value="' . $ID . '"> <input type="text" name="Text" id="editruta" placeholder="Ny" value="' . $row2["Text"] . '" required> <textarea name="story" id="storyedit">' . $row2["Story"] . '</textarea><br> <input type="submit" class="button" value="Ändra"> </div> </form>'; } } catch (PDOException $e) { print 'Exception : ' . $e->getMessage();