Jump to content

News Article Page


wizzkid

Recommended Posts

I have manage to create my own script that add news article, however, I would like to add a comment form below the news article. How can I relate the news and the comments? also, when I delete the articles, it should also delete the comments in mysql.

 

Your help is highly appreciated!

Link to comment
Share on other sites

So far this is the only code I have for now. I still dont have the code for comments.

 

=======

html

=======

<?php

include_once ('post_news.php');

?>

 

<form Action="add_news.php" Method="post">

<input name="postdate" type="text" id="postdate">

<input name="title" type="text" id="title">

<textarea name="newstext" cols="60" rows="15" id="newstext"></textarea>

<input type="submit" name="submit" value="Submit">

<input type="reset" name="reset" value="Reset">

</form>

 

==============

php - post_news.php

==============

<?php 

 

ini_set ('display_errors', 1);

error_reporting (E_ALL & ~E_NOTICE);

 

if (isset ($_POST['submit']))

 

{

 

require_once ('inc/dbConfig.php');

 

// Define the query.

$query = "INSERT INTO news (id, postdate, title, newstext) VALUES

(0,'{$_POST['postdate']}', '{$_POST['title']}','{$_POST['newstext']}')";

 

// Execute the query.

if (@mysql_query ($query)) {

print "<p>Data has been added.</p>";

} else {

print "<p>Could add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";

}

 

mysql_close();

 

}

 

?>

 

=====

db structure

======

id int(10) unsigned NOT NULL auto_increment,

  postdate timestamp(14),

  title varchar(50) NOT NULL,

  newstext text NOT NULL,

  PRIMARY KEY (id),

  KEY postdate (postdate)

 

 

Thanks a lot for your help guys! :)

 

Link to comment
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.