Jump to content

edit and update post


jalaladdin

Recommended Posts

i wrote this code for edit posti wrote this query for mesage's table

$Query = mysql_query("SELECT * FROM `message` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1 ");
and i fetch data from mysql database with function
$row_rsEdit = mysql_fetch_array($Query);
and i wrote this query for update post
$EditNews = mysql_query ("UPDATE `message` SET `title` = '".$title."', `text1` = '".$text1."' WHERE `id` = '".$_POST['id']."' LIMIT 1");
but this code not run please guied me how can i change this code for update post and save in database
<input type="hidden" name="Act" value="<?php echo (isset($row_rsEdit)) ? "EditNews" : ""; ?>"> <?php echo (isset($row_rsEdit)) ? '<input type="hidden" name="id" value="'.$row_rsEdit['id'].'">' : ''; ?> <div align="center"> <table border="0" width="460" dir="rtl" cellpadding="0"> <tr> <td align="center" colspan="2"><?php echo $Prompt; ?></td> </tr>
all code for edit post
<?php $con = mysql_connect("localhost","root","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("admin", $con);if ( isset($_GET['id']) && ($_GET['id'] !== "") ){ $Query = mysql_query("SELECT * FROM `message` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1 "); $row_rsEdit = mysql_fetch_array($Query); if(mysql_num_rows($Query)>0){ if ( isset($_POST['Act']) && ($_POST['Act'] == "EditNews") ){ $title=mysql_real_escape_string($_POST['title']); $text1=mysql_real_escape_string($_POST['text1']); $EditNews = mysql_query ("UPDATE `message` SET `title` = '".$title."', `text1` = '".$text1."' WHERE `id` = '".$_POST['id']."' LIMIT 1"); if ( $EditNews ) { $Prompt = '<font color="green"><b> update post successfully </b></font>'; } else { $Prompt = '<font color="red"><b>sorry</b></font>'; }}else{$Prompt = false;} }}?><form action="" method="POST" id="signupForm" name="posts"> <input type="hidden" name="Act" value="<?php echo (isset($row_rsEdit)) ? "EditNews" : ""; ?>"> <?php echo (isset($row_rsEdit)) ? '<input type="hidden" name="id" value="'.$row_rsEdit['id'].'">' : ''; ?> <div align="center"> <table border="0" width="460" dir="rtl" cellpadding="0"> <tr> <td align="center" colspan="2"><?php echo $Prompt; ?></td> </tr> title:<input type="text" name="title" id="man2" size="50" dir="rtl" class="bg-blue02" value="<?php echo $row_rsEdit['title']; ?>"><p>text:<textarea name='text1' rows='2' id='text1' style='WIDTH:80px; HEIGHT:100%;'><?php echo $row_rsEdit['text1']; ?></textarea> <script type='text/javascript'> //<![CDATA[ // Replace the <textarea id='editor1'> with an CKEditor instance var editor = CKEDITOR.replace( 'text1' ); //]]> </script> <input type="submit" name="send" value="send" /> </form>
Link to comment
Share on other sites

Well, start printing things out. Print out $_GET['id'] so you can see what the value is, and print the other values from $_POST that you're using in the if statements. If you're trying to figure out what the code is doing you need to know what data it's working with.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...