Jump to content

News system help


ItsWesYo

Recommended Posts

I have created a news system using mysql.The problem is that I don't have an edit and delete system for it. Right now, I add news with a form thats on web page. It has forms for author, title and body. When submitted, it adds and ID to it and adds the date to it.

What I want now is an edit and delete function for it. So, what I am asking, how do I create a script for both of them that I can select a news title sorted by the ID from a drop down menu and select 'edit' or 'delete'.

I looked at a script that was similar to the one I was describing, but it used 'users' as an example and I didn't understand it.
Link to comment
https://forums.phpfreaks.com/topic/36021-news-system-help/
Share on other sites

Well it's not a simple matter to just tell you how to make the entire one, they often are highly customizable. If your asking for someone to do it for you try the freelance section.

Basically though you will need something like this for the delete page:

[code]
if ( isset ($myarticleid) ) {
    $query = mysql_query("DELETE FROM table WHERE id = '$myarticleid'");
}
[/code]

Now for my news system I'm designing my delete php file was 87 lines long, but granted I make a lot of options, security guards, and 1DI0T error prevention

As for the editing, thats an entirley different matter.

Not to depress you but for my editing page for articles on my news system the PHP is 187 lines long and the HTML is 312. (I do format though)

Basically your editing page will follow the same line as your submission screen but instead of

[code]
$query = mysql_query("INSERT INTO articletable value = '$value', value2 = '$value2'");
[/code]

You change it to

[code]
$query = mysql_query("UPDATE articletable SET value = '$value', value2 = '$value2' WHERE articleid = '$articleid'");
[/code]

Hope this helps in some way
Link to comment
https://forums.phpfreaks.com/topic/36021-news-system-help/#findComment-170899
Share on other sites

For the edit part, use your existing form. Run a query to pull the information from the database using a link or drop down or what have you to pass the id of the record into the query. Retrieve your data and place into nice neat vars.. $title, $author and $body. In your form set your form fields to have value="<?=$title ?>" value="<?=$author ?>" value="<?=$body ?>" respectively for each field.


Your form should reload the info and allow you to resubmit it. When you resubmit, like SMC said, use the UPDATE query instead of the INSERT.

Hope this helps a little


Link to comment
https://forums.phpfreaks.com/topic/36021-news-system-help/#findComment-170949
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.