Move table records with the click of a link?
Posted: Thu Jun 25, 2009 10:25 am
Hello Experts!
I have a CMS dashboard that lists all current and old news.
I have links that let me EDIT and DELETE any story by taking me to another page.
What I need now is a third link to ARCHIVE STORY that simply lets me move a current news story into the old news table without leaving the page, but I don't know A) how to code the anchor tag for this, or B) if there is MOVE sql statement or if it's simply INSERT and then DELETE.
Here is code that works from my DELETE page.
And here are the three links (third link shouldn't leave the page, just execute the MOVE)
This has been troubling me for a couple of days now. I appreciate anyone's effort to solve this dastardly dilemma.
Arlen
I have a CMS dashboard that lists all current and old news.
I have links that let me EDIT and DELETE any story by taking me to another page.
What I need now is a third link to ARCHIVE STORY that simply lets me move a current news story into the old news table without leaving the page, but I don't know A) how to code the anchor tag for this, or B) if there is MOVE sql statement or if it's simply INSERT and then DELETE.
Here is code that works from my DELETE page.
Code: Select all
$stmt = $conn->stmt_init();
if ($stmt->prepare($sql)) {
// bind the query parameters
$stmt->bind_param('i', $_GET['storyID']);
// bind the result to variables
$stmt->bind_result($storyID, $headline, $created);
// execute the query, and fetch the result
$OK = $stmt->execute();
$stmt->fetch();
}
}
// if confirm deletion button has been clicked, delete record
if (array_key_exists('delete', $_POST)) {
$sql = 'DELETE FROM news WHERE storyID = ?';
$stmt = $conn->stmt_init();
if ($stmt->prepare($sql)) {
$stmt->bind_param('i', $_POST['storyID']);
$deleted = $stmt->execute();
}
}Code: Select all
<td><a href="updateNews.php?storyID=<?php echo $row['storyID']; ?>">EDIT</a></td>
<td><a href="deleteNews.php?storyID=<?php echo $row['storyID']; ?>">DELETE</a></td>
<td><a click here to>MOVE TO ARCHIVES</a></td>Arlen