Can not update a row in PHP

General discussion on technical and managerial topics
no avatar
subratmca85
 
Posts: 2
Joined: Wed Mar 20, 2013 12:51 pm

Can not update a row in PHP

by subratmca85 » Wed Apr 03, 2013 3:47 pm

Here is the update codes:
<?php

//$id = $_GET['id'];

if(isset($_POST['update']))
{
$sql= "UPDATE student SET rollno='".$_POST[rollno]."',name='".$_POST['name']."', phone='".$_POST[phone]."',address='".$_POST['address']."',salary='".$_POST[salary]."'
WHERE rollno='".$rollno."'";

if (!mysqli_query($con,$sql))
{
die('Updation failed...Please try again.'. mysqli_error());
}
else
{
echo "Database updated successfully";
}
}

$result = mysqli_query($con,"SELECT * FROM student order by rollno");

echo "<table border='3' bgcolor='#FF66FF'>
<tr>
<th>Roll</th>
<th>Name</th>
<th>Phone</th>
<th>Address</th>
<th>Salary</th>
<th>Edit/Delete</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row[rollno] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row[phone] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td>" . $row[salary] . "</td>";
echo "<td colspan='6' align='center'><a href=edit.php?id=".$row['rollno'].">Edit</a>&nbsp;/<a href=delete.php?id=".$row['rollno'].">Delete</a></td>";
echo "</tr>";
}
echo "</table>";
?>

Please help...

Return to General Discussion