AV Posted March 9, 2008 Share Posted March 9, 2008 if(isset($_GET['modify'])){ $id = $_GET['modify']; $result2 = mysql_query("SELECT * FROM news WHERE id='$id'") or die(mysql_error()); $row = mysql_fetch_array($result2); echo "<table class='table'>"; echo "<form action='news.php' method='post'>"; echo "<tr><td>Title:</td>"; echo "<td><input type='text' value='".$row['title']."' name='title' class='login'></td></tr>"; echo "<tr><td>Content:</td><td><input type='textarea' value='".$row['content']."' cols='50' rows='20' name='content' class='login'></td></tr>"; echo "<tr><td><input type='submit' name='submit' value='OK' class='login_button'></td></tr>"; echo "</form></table>"; }else{ if(isset($_POST['submit'])){ $title = $_POST['title']; $content = $_POST['content']; $done = mysql_query("UPDATE news SET title='$title', content='$content' WHERE id='$id'") or die(mysql_error()); if(!$done){ echo 'Something gone wrong!'; }else{ echo 'Updated.'; } This is my code. When I try to correct something in the textarea (content) and push OK, the 'Updated.' appears. Problem is that data in table isn't updated. I hope you understand me, thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/95218-update-data-in-mysql-problem/ Share on other sites More sharing options...
trq Posted March 9, 2008 Share Posted March 9, 2008 There is no such input type as 'textarea', this... echo "<td><input type='text' value='".$row['content']."' cols='50' rows='20' name='content' class='login'></td></tr>";code] should be.... [code]echo "<td><textarea name='content' cols='50' rows='20' class='login'>{$row['content']}</textarea>></td></tr>"; [/code] Quote Link to comment https://forums.phpfreaks.com/topic/95218-update-data-in-mysql-problem/#findComment-487708 Share on other sites More sharing options...
AV Posted March 9, 2008 Author Share Posted March 9, 2008 Thanks for your reply! But it still doesn't update the data in table Quote Link to comment https://forums.phpfreaks.com/topic/95218-update-data-in-mysql-problem/#findComment-487716 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.