Jump to content

Recommended Posts

Hey guys, me again. I want to thank you again for helping resolve the issue I had earlier today with the php sessions. You all rock! :)

 

I have approached an issue that I am not quite sure how to do exactly. In reference to the same content of my previous post, I have a form that, when filled out by a user, adds it's contents to a MySQL database and displays them in a very nice interface I have designed. Along with all of this, my system automatically adds 'options' to each display of input, i.e. 'edit' 'delete', etc. These work flawlessly.

 

My question is, I am wanting to add a couple of new features that would require for the displayed information to be removed from the main page then moved and displayed on it's new page, consider this an option like 'Archive'

 

What would be the best way for me to do this, code wise?

 

Thanks again in advance for your assistance, this community is definitely very helpful.

Link to comment
https://forums.phpfreaks.com/topic/269963-moving-content/
Share on other sites

Keep a flag with the records that indicates whether something is archived or not. The main page shows the ones with archived=0 and the archive page shows the ones with archived=1.

 

[edit] Assuming that "archived" doesn't entail anything more than where the records show up. Like whether they've been backed up somewhere.

Edited by requinix
Link to comment
https://forums.phpfreaks.com/topic/269963-moving-content/#findComment-1388065
Share on other sites

Add a field to the table called "archived."  Set that field to 0.  Add a button called "archive this" that will flip the "archived" field on a post to 1.  Have your main page only show items where archived = 0.  Have an archive page if you wish, which only shows archived = 1.

 

What else are you looking for here?

Link to comment
https://forums.phpfreaks.com/topic/269963-moving-content/#findComment-1388073
Share on other sites

Add a field to the table called "archived." Set that field to 0. Add a button called "archive this" that will flip the "archived" field on a post to 1. Have your main page only show items where archived = 0. Have an archive page if you wish, which only shows archived = 1.

 

Additionally, what would be the best way to do this? :)

 

I already have the button created and in place

Edited by trg86
Link to comment
https://forums.phpfreaks.com/topic/269963-moving-content/#findComment-1388180
Share on other sites

Submit the form with an id of what you're archiving in the url such as archive.php?id=id

 

Just call it by using

$id = mysql_real_escape_string($_GET['id']);

 

Then use sql to update the information

$sql = "UPDATE `table` SET `archive` = '1' WHERE `id` = '$id'";

 

To call all of them that aren't archived just use a while loop and a where clause as followed:

 

$sql = "SELECT * FROM `table` WHERE `archive` = '0'";

$result = mysql_query($sql,$connection) or die("Error connecting to the database");

while($row = mysql_fetch_array($result)) {
// How you want to display it here. Examples shown below
$title = $row['title'];
$info = $row['info'];
$id = $row['id'];

// Using so many echos to keep it easy to read
echo "$title<br>";
echo "$info<br>";
echo "<form action='archive.php?id=$id' method='post'>";
echo "<input type='submit' value='Archive This'>";
echo "</form>";

}

Edited by ExtremeGaming
Link to comment
https://forums.phpfreaks.com/topic/269963-moving-content/#findComment-1388186
Share on other sites

Submit the form with an id of what you're archiving in the url such as archive.php?id=id

 

Just call it by using

$id = mysql_real_escape_string($_GET['id']);

 

Then use sql to update the information

$sql = "UPDATE `table` SET `archive` = '1' WHERE `id` = '$id'";

 

To call all of them that aren't archived just use a while loop and a where clause as followed:

 

$sql = "SELECT * FROM `table` WHERE `archive` = '0'";

$result = mysql_query($sql,$connection) or die("Error connecting to the database");

while($row = mysql_fetch_array($result)) {
// How you want to display it here. Examples shown below
$title = $row['title'];
$info = $row['info'];
$id = $row['id'];

// Using so many echos to keep it easy to read
echo "$title<br>";
echo "$info<br>";
echo "<form action='archive.php?id=$id' method='post'>";
echo "<input type='submit' value='Archive This'>";
echo "</form>";

}

 

Thank you for the example, although I did not need the whole code, just needed to add this option to my current structure. I also took previous advice that I needed to set it up just like my already complete 'edit' function, which I have done. I have this successfully working now, just need to make the archive page to display just the archived leads...

Edited by trg86
Link to comment
https://forums.phpfreaks.com/topic/269963-moving-content/#findComment-1388189
Share on other sites

What's the best way to do what?  We don't write coded for you here unless you're very lucky and ExtremeGaming happens to be around.  If you honestly can't figure this out, either hope to keep receiving his good graces, or pay someone to implement it for you.

Link to comment
https://forums.phpfreaks.com/topic/269963-moving-content/#findComment-1388190
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.