question of update data in php
$query ="SELECT * FROM activites";
$queryc = mysql_query($query);
while( $row = mysql_fetch_array($queryc))
{
echo '<table>';
echo '<tr><th colspan="3"><form action="CRUD/modiftitle.php" method="POST"><input type="text" name="title" value="'.$row['title'].'" /><input type="submit" name="modify" value="Modify" /></form></th></tr>';
echo '</table><br />';
}
echo '</center>';
?>
i have this code, the problem is th开发者_高级运维at when i try to modify one data all o them will be the same as the modified! here is the modify file:
<?php
$connection = @mysql_connect(localhost, 'root', '');
if (!$connection){
echo 'not connect';
}
mysql_select_db('bena');
//Update content
$content = $_POST['content'];
$sql = "UPDATE activites SET content = '$content'";
$result = mysql_query( $sql, $connection );
if($result)
echo "Update was successfully complete! ";
?>
The query UPDATE activites SET content = '$content'
needs a WHERE statement, which describes what objects that should be updated
精彩评论