wizzkid Posted September 28, 2010 Share Posted September 28, 2010 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 https://forums.phpfreaks.com/topic/214623-news-article-page/ Share on other sites More sharing options...
litebearer Posted September 28, 2010 Share Posted September 28, 2010 might help if you show some of your current code as well as your db table structure Link to comment https://forums.phpfreaks.com/topic/214623-news-article-page/#findComment-1116767 Share on other sites More sharing options...
wizzkid Posted September 28, 2010 Author Share Posted September 28, 2010 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 https://forums.phpfreaks.com/topic/214623-news-article-page/#findComment-1116771 Share on other sites More sharing options...
wizzkid Posted September 28, 2010 Author Share Posted September 28, 2010 Also, if you guys could help me on how to add a photo on article, it will be a great help! much better if the photo will be save on the servers folder instead on database. hope you can give me an insight. Thanks! Link to comment https://forums.phpfreaks.com/topic/214623-news-article-page/#findComment-1116772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.