Jump to content

ryeman98

Members
  • Posts

    286
  • Joined

  • Last visited

    Never

Everything posted by ryeman98

  1. I get this error when I try to delete an article: I don't know how to make it so the id is carried over to the delete part of the code. Here is the entire article.php code: <?php if ((isset ($_GET['article_id']))) { echo "<form name=\"delete\" action=\"article.php?action=delete\" method=\"post\">"; $id = $_GET['article_id']; //I want this id carried over to the delete part at the bottom $query = mysql_query("SELECT * FROM news WHERE id = $id"); $result = mysql_fetch_array($query); $getarticle = $result['id']; $title = $result['title']; $date = $result['date']; $content = $result['content']; echo "<p class=\"hide\">"; echo $getarticle; echo "</p><h3>"; echo $title; echo "</h3><p>"; echo $date; echo "</p><p>"; echo $content; echo "</p><p> <input type=\"submit\" name=\"delete\" value=\"Delete\" /></form></p>"; } if ($_GET['action'] == "new") { $date = date("F j, Y"); $verify = rand(1000, 9999); echo " <table border=0 cellpadding=0 cellspacing=0> <form name=\"addarticle\" action=\"/article.php?action=add\" method=\"post\"> <tr valign=top><td><strong>Title:</strong></td> <td><input type=\"text\" name=\"title\" size=\"60\" /></td></tr> <tr valign=top><td><strong>Date:</strong></td> <td>".$date."</td></tr> <tr valign=top><td><strong>Content:</strong></td> <td><textarea name=\"content\" maxlength=\"10000\" cols=\"50\" rows=\"10\"></textarea></td></tr> <tr valign=top><td><strong>".$verify."</strong></td> <td><input type=\"text\" name=\"verify\" size=\"4\" maxlength=\"4\" /></td></tr> <tr align=right><td></td><td><input type=\"submit\" name=\"submit\" value=\"Add Article\" /></td></tr> </form></table>"; } elseif ($_GET['action'] == "add") { if (!$_POST['title'] || !$_POST['content'] || !$_POST['verify'] ) { die("You did not fill in all the required fields. Use your browser's back button to retry."); } $title = $_POST['title']; $date = date("F j, Y"); $content = $_POST['content']; $insert = ("INSERT INTO news (title, date, content) VALUES ('$title', '$date', '$content')"); $add = mysql_query($insert) or die(mysql_error()); echo "Your article has been submitted. Go <a href=\"/index.php\">Here</a> to view it."; } elseif ($_GET['action'] == "delete") { //I want the id carried down here $id = $_POST['article_id']; $query = $_POST['query']; $result = $_POST['result']; $getarticle = $_POST['getarticle']; $title = $_POST['title']; $date = $_POST['date']; $content = $_POST['content']; $id = $_GET['article_id']; $delete = mysql_query("DELETE FROM news WHERE id = $id") or die(mysql_error()); } ?> Within the code I mentioned where I want the id to be carried and I want to delete the article when I go to article.php?action=delete Thanks for the help, Rye
  2. Well I guess I'll just explain it again. I have a page called article.php and it displays whichever article a user wants to view. The link to get to an article is: Now I want to have a form within the article.php file which will only display when I go to: I've attempted making it work but it was no good. This is the code for article.php: <?php include("config.php"); //All of this code is fine if ((isset ($_GET['article_id']))) { $id = $_GET['article_id']; $query = mysql_query("SELECT * FROM news WHERE id = $id"); $result = mysql_fetch_array($query); $getarticle = $result['id']; $title = $result['title']; $date = $result['date']; $content = $result['content']; echo "<p class=\"hide\">"; echo $getarticle; echo "</p><h3>"; echo $title; echo "</h3><p>"; echo $date; echo "</p><p>"; echo $content; echo "</p>"; } ?> <?php //This is the code that won't work if ((isset ($_GET['action'] = ['new']))) { $date = date("F j, Y"); echo "<form name=\"addarticle\" action=\"/article_submit.php\" method=\"post\"> Title: <input type=\"text\" name=\"title\" /> Date: $date Content: <textarea name=\"content\" maxlength=\"10000\"></textarea> <input type=\"submit\" name=\"submit\" value=\"Add Article\" /> </form>"; } ?>
  3. I don't normally do this but I'm in a rush...Chigley, I sent you a message containing my problem and I forgot to save it so...yeah... Sorry if you'd consider this spamming but I still need help, technically.
  4. That really helped but I've run into another problem, unfortunately. As stupid as I am, I didn't call up the articles title, date, or content...any ideas on how I could so I can display each thing separately like this: <?php Mysql stuff here... echo $title; echo $date; echo $content; ?>
  5. I still haven't received help. Normally I am a very patient person but for some reason, tonight I just don't feel like it... :-\
  6. What kind of server are you on? Usually, if it's free, they won't let you use the mail() function.
  7. Wow...OK...here is my problem: On the main page of my site, I have an article that will display 3 sentences (I haven't figured out how to do that yet...) and at the bottom it has a link to article.php?article_id=#. My problem is that when I go there, it will say: Here is my code for article.php <?php include("config.php"); if ((isset ($_GET['article_id']))) { $id = $_GET['article_id']; $query = "SELECT id FROM news WHERE id = $id"; $getarticle = mysql_query($query); echo $getarticle; } ?> Any help is good...thanks, Rye
  8. I just noticed PCNerd was on...maybe he could lend his helping hand?
  9. I thought that would work but I wasn't too sure so I didn't say anything. AJAX is great!
  10. Your English is awful, no offense. Mostly we help with code that is already written but... I don't understand what you mean. Show a respective state when a country is selected in a drop down menu?
  11. Probably not. If a user has individual info, then you'd just be calling one table. If you want some other table, it wouldn't be completely user related so it wouldn't matter if there were 500 requests for a single table. You just need to make arrays that include calling up a certain table. If you're confused about that, I'll try to help describe it further...
  12. No, I'd say use a column for each different information for the user, not a whole new table, that could create lag because you'd have to call up a lot of tables.
  13. I'd create a table and call it users and have all the user info. in there. Then make tables for anything else... That's how I'd do it anyway...
  14. I just got an idea but... Would this work for for the link? <?php $id = ("SELECT id FROM articles WHERE id") echo "<a href=\"/index.php?article=". $id ."\">Full Story</a>"; ?> Just a shortened version but would that work?
  15. Well...that kind of answers half...what would the link be to display the full article? I'm sorry if I'm getting annoying but I get frustrated when I try to figure it out for days and have to start over completely. Yes, my own fault I know but I'm learning... :-\
  16. I can't edit my post... I wanted to say that I know how to display the article previews but I just don't know how to use the GET method to call the entire article from the database.
  17. I learned all the languages I know from w3schools.com
  18. I mean like... example: A blog has a few sentences of the article, then you have to click on a link to get to the full article. the url would be like: http://www.somesite.com/index.php?id=546187
  19. I don't think I completely understand the GET method...but here is what I want to do. I will be inserting multiple news articles into a database that will display on my website. On the index it'll only show a few sentences and then the rest, people will have to click on a link to get the full story. How can I make it so that they can click and I can just use the GET method to call up the id for the article? (Each article will have an id and a title and I want to display them by the id) Thanks in advance, Rye
  20. Wouldn't it be easier just to use a database? You would have a lot more security...
  21. Case statements are just adding a lot more work. I like the solution that I have, thanks anyway!
  22. Alright, that sounds like it'll work great. Thanks!
  23. I'm not sure I completely understand...where will the data be stored?
×
×
  • 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.