Jump to content

Update data in MySQL problem


AV

Recommended Posts

    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.

Link to comment
https://forums.phpfreaks.com/topic/95218-update-data-in-mysql-problem/
Share on other sites

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]

Archived

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

×
×
  • 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.