Mod-Jay Posted September 4, 2010 Share Posted September 4, 2010 Error: No error, Having Trouble Making My Blod Editer.. Do what You can Please.. Code: <?php if(isset($_GET['action']) && $_GET['action'] == 'edit') { echo " <hr><center><h1>Editing News $name</h1> <form action='news.php?action=edit123' method='POST'> Your News Name:<br> <input id='name' type='text' name='name' autocomplete='off' maxlength='25'><br>Your News Description: <br> <textarea name='descrr' id='descrr' rows='3' cols='60' maxlength='250'> </textarea><br> <input type='submit' name='submit' value='Add News'> </form></center><hr> "; } ?> <?php if(isset($_GET['action']) && $_GET['action'] == 'edit123') { if( isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; mysql_query("UPDATE blog SET name=name WHERE descr=$descrr") or die(mysql_error()); echo "News: $name Updated"; } else { echo "Name is Empty"; } } ?> LOL @ Thorpe, Yea i do. I Need to Make Edit123 update the One Selected, And "Editing News $name" Have the One Selected, Thanks in Advanced. Once I have the Things i asked for . Im Good. Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/ Share on other sites More sharing options...
trq Posted September 4, 2010 Share Posted September 4, 2010 Do you have a question? Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107053 Share on other sites More sharing options...
JasonLewis Posted September 4, 2010 Share Posted September 4, 2010 I need a new computer, and a new TV as well I think, once I have them I'm good. It seems as though you are demanding code to be written for you, not going to happen like that mate. Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107062 Share on other sites More sharing options...
Joshua F Posted September 4, 2010 Share Posted September 4, 2010 I just put together a quick simple code.. It might not be secure or anything, but it works I think. You might need to edit it a little. You'll prob have to edit the part that is like news.php?action=edit&id=<?php echo $list_b['id'];?> On line 16. <?php if($_GET['action'] == 'edit') { $id="{$_GET['id']}"; if ($list_q = mysql_query("SELECT * FROM blog WHERE ID='$id'")) { if (mysql_num_rows($list_q)) { while($list_b=mysql_fetch_array($list_q)) { if(empty($C_Error) and !empty($_POST['Submit'])) { mysql_query("UPDATE toplist SET name='". realEscape($_POST['name']) ."', descr='". realEscape($_POST['descr']) ."' WHERE id=$id") or die(mysql_error()); echo 'News Updated'; } ?> <form action="news.php?action=edit&id=<?php echo $list_b['id'];?>" method="post"> <strong>Name:</strong> <input type="text" class="textbox" name="name" maxlength="25" size="25" value="<?php echo $list_b['name'];?>" /> <strong>Content:</strong> <textarea name="descr" rows="10" cols="50%" maxlength="10000"><?php echo $list_b['descr'];?></textarea> <input type="submit" class="button" name="Submit" value="Edit News" /> </form> <?php }}}} ?> <?php if($_GET['action'] == 'delete') { $id="{$_GET['id']}"; mysql_query("Delete * from blog WHERE id=$id") or die(mysql_error()); echo 'News Deleted'; } ?> State: Untested Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107083 Share on other sites More sharing options...
wildteen88 Posted September 4, 2010 Share Posted September 4, 2010 The following should be placed outside of the while loop. if(empty($C_Error) and !empty($_POST['Submit'])) { mysql_query("UPDATE toplist SET name='". realEscape($_POST['name']) ."', descr='". realEscape($_POST['descr']) ."' WHERE id=$id") or die(mysql_error()); echo 'News Updated'; } Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107085 Share on other sites More sharing options...
Joshua F Posted September 4, 2010 Share Posted September 4, 2010 The following should be placed outside of the while loop. if(empty($C_Error) and !empty($_POST['Submit'])) { mysql_query("UPDATE toplist SET name='". realEscape($_POST['name']) ."', descr='". realEscape($_POST['descr']) ."' WHERE id=$id") or die(mysql_error()); echo 'News Updated'; } Oops, thanks for that correction. I just wrote this up in like 2 mins, and was going fast. Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107087 Share on other sites More sharing options...
Mod-Jay Posted September 4, 2010 Author Share Posted September 4, 2010 Error: The edit is supposed to add the updated into the database, but it dont add... Help please Code: <?php if(isset($_GET['action']) && $_GET['action'] == 'edit') { $id="{$_GET['id']}"; if ($list_q = mysql_query("SELECT * FROM blog WHERE ID='$id'")) { if (mysql_num_rows($list_q)) { while($list_b=mysql_fetch_array($list_q)) { if(empty($C_Error) and !empty($_POST['Submit'])) { mysql_query("UPDATE blog SET name='". realEscape($_POST['name']) ."', descr='". realEscape($_POST['descr']) ."' WHERE id=$id") or die(mysql_error()); echo 'News Updated'; } ?><hr><center> <form action="news.php?action=edit&id=<?php echo $list_b['id'];?>" method="post"> Name:<br> <input type="text" class="textbox" name="name" maxlength="25" size="25" value="<?php echo $list_b['name'];?>" /><br> Content:<br> <textarea name="descr" rows="5" cols="60" maxlength="10000"><?php echo $list_b['descr'];?></textarea><br> <input type="submit" class="button" name="Submit" value="Edit News" /> </form></center> <?php }}}} ?> Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107105 Share on other sites More sharing options...
trq Posted September 4, 2010 Share Posted September 4, 2010 Can you please refrain from opening new threads for what is esentually the same topic. Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107109 Share on other sites More sharing options...
Mod-Jay Posted September 4, 2010 Author Share Posted September 4, 2010 Hehe sorry Xd EDIT***** FIXED Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107112 Share on other sites More sharing options...
Mod-Jay Posted September 4, 2010 Author Share Posted September 4, 2010 Error: No error, IT dont loop, Idk why.. help please Code: <?php $rr = mysql_query("SELECT * FROM news"); while($r = mysql_fetch_array($rr)) { $name1=$r["name"]; $desr=$r["desr"]; $link1=$r["link"]; $date1=$r["date"]; $datem1=$r["datem"]; } echo " <div class='cs_article'> <div class='left'> <h2>$name1</h2> <p>$desr</p> <div class='button'><a href='$link1'>Read more</a></div> </div> <div class='right'> <h1>$name1</h1> </div> </div> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107115 Share on other sites More sharing options...
pornophobic Posted September 4, 2010 Share Posted September 4, 2010 Because you're looping the assigning of names, not the entire method. Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107116 Share on other sites More sharing options...
trq Posted September 4, 2010 Share Posted September 4, 2010 Mod-Jay. You really need to step back a little and learn some basics. Coming to a board and asking for help with every simple little problem isn't going to get you anywhere fast. Theres a good free book in my signature (Hudzilla) that should get you started. Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107117 Share on other sites More sharing options...
Mod-Jay Posted September 4, 2010 Author Share Posted September 4, 2010 I know Mostly Everything i need to know.. Its just somethings im alittle off.. Im Posting on here Because i cant remember how to do it or i dont know how to.. Thanks Mod-Jay Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107186 Share on other sites More sharing options...
wildteen88 Posted September 4, 2010 Share Posted September 4, 2010 pornophobic told you what is wrong in in his post here Quote Link to comment https://forums.phpfreaks.com/topic/212481-just-need-help/#findComment-1107225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.