break; } else { $title = getPageTitle($url); $query = "INSERT into links (userID, url, title, timestamp) VALUES (?, ?, ?, now())"; $params = [$userID, $url, $title]; $lastInserted = editQuery($query, $params); if (strlen($tags) > 0) { $tagString = strtolower($tags); $tags = stringToArray($tagString); $tags = array_unique($tags); foreach ($tags as $tag) { $query = "SELECT * from tags WHERE tag = ?"; $params = [$tag]; $res = selectQuery($query, $params); if (count($res) == 0) { $query = "INSERT into tags (tag) VALUES (?)"; $params = [$tag]; editQuery($query, $params); } } foreach ($tags as $tag) { $query = "SELECT tagID from tags WHERE tag = ?"; $params = [$tag]; $res = selectQuery($query, $params); $tagID = $res[0]["tagID"]; $query = "INSERT into taggedlinks (tagID, linkID) VALUES (?, ?)"; $params = [$tagID, $lastInserted]; editQuery($query, $params); } } }
function deleteEntry($id) { $query = "DELETE from links where linkID = ?"; $params = [$id]; editQuery($query, $params); }
function updateTitle($linkID, $newTitle) { $query = "UPDATE links set title=? WHERE linkID = ?"; $params = [$newTitle, $linkID]; editQuery($query, $params); }
<?php require_once 'config.php'; $db = dbconnect(); $action = $_REQUEST['action']; $error = ""; $message = ""; if ($action == 'editquery') { if ($_POST[query_id] > 1) { $fields = fetchRow('select * from queries where query_id=' . $_POST[query_id]); $query_id = $fields[0]; $name = $fields[1]; $description = $fields[2]; $query = $fields[3]; } editQuery($name, $description, $query, $query_id); exit; } else { if ($action == 'delete') { $res = dbQuery('delete from queries where query_id=' . $_GET[query_id]); if ($db->affected_rows >= 1) { $info = 'Query deleted.'; } else { $error = "Unable to delete query: <br/> {$error}"; } } else { if ($action == 'copyquery') { $res = dbQuery("insert into queries select null, concat(b.name, '_copy'), b.description, b.query, NOW(), NULL, NULL from queries b where b.query_id = {$_GET['query_id']}"); if ($res) { $info = "Query copied."; }