hi, i have placed a table between a web page which display details of a user dynamically. Here is the code for it

<?php
$con=mysqli_connect("abc.com","avc","abc","abc");
// Check connection
if (mysqli_connect_errno()) 
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM employee");
echo "<table class='table table-striped table-bordered table-hover'>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Country</th>
<th> Email</th>
<th>Edit</th>
</tr>
</thead>";
while($row = mysqli_fetch_array($result)) 
{
echo "<tbody data-link='row' class='rowlink'>";
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['country'] . "</td>";
echo "<td>" . $row['email'] . "</td>";    
echo "<td><a href=\"admin_edit_property.php?id=".$row['id']."\">Edit</a></td>";
echo "</tr>";
echo "</tbody>"; 
}

the look of the page will be something like this

Id Name  Country Email          Edit
1  user  abc     abc@gmail.com  edit

when a user clicks on the edit link, the code on page admin_edit_property.php is executed. code for this page is

<?php
include('admin_session.php');

$con=mysqli_connect("abc.com","abc","abc","abc");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$name = mysqli_real_escape_string($con, $_POST['name']);
$country = mysqli_real_escape_string($con, $_POST['country']);
$email = mysqli_real_escape_string($con, $_POST['email']);

$sql = "UPDATE employee SET name='".$name."',country='".$country."',email='".$email."' WHERE id ='".$empid."'";

if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
header("Location: index.php");
exit;

mysqli_close($con);
?>

<form class="form-horizontal" role="form" action="<?php $_PHP_SELF ?>" enctype="multipart/form-data" method="post">

<div class="form-group">
<label class="col-lg-3 control-label">Name:</label>
<div class="col-lg-8">
<input class="form-control" value="" type="text" name="name">
</div>
</div>

<div class="form-group">
<label class="col-lg-3 control-label">:Country</label>
<div class="col-lg-8">
<input class="form-control" value="" type="text" name="country">
</div>
</div>

<div class="form-group">
<label class="col-lg-3 control-label">Email:</label>
<div class="col-lg-8">
<input class="form-control" value="" type="text" name="email">
</div>
</div>

<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-8">
<input class="btn btn-primary" value="Save Changes" type="submit" name="submit">

</div>   
</div>
</form>

I din't know why but this code does not seem to work. when i run it it simply redirects me to index.php page but does not update the value. would appreciate all help

Member Avatar for iamthwee

You need to use $_GET to pull out the url id.

can you plz tell me how can i do it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.