Dear Experts,

I have following codes

$sql = "SELECT * from contacts order by name" ;
$select = mysqli_query($con,$sql);
//echo ($row);
while($row = mysqli_fetch_array($select))
    echo "<tr>";
    echo "<td> <a href='edit.php?id=".$row['id']."'>
    <img border=noborder src=images/pencil.png title=Display></a></td>";
    echo "<td align='left'> " . $row["name"].  "</td>";
    echo "<td> " . $row["moba"]. "</td>";
    echo "<td> " . $row["city"]. "</td>";
    echo "<td> " . $row["country"] . "</td>";
    echo "</tr>";
?>        </tbody>

and Edit.php has this data

        $sno =$_GET['id']; 
        $query ="SELECT * FROM contacts WHERE id = $sno ";
        $result=mysqli_query($con, $query);

        if ($result){

                while ($row = mysqli_fetch_array($result))
               echo $row['name']."<br>";
               echo $row['moba'];
              echo "no data found";

If I press a link then related data must appear in related textboxes against selected id like shown in image


Please help

You could use something like Javascript using something like the code below:

<!DOCTYPE html>
        <script type="text/javascript" src="" /></script>
            Name: <input type="text" id="contactName"/>
            <input type="button" value="Click Me" onClick="$('#contactName').val('Contacts Name');" />

So what you can do is replace echo "<td align='left'> " . $row["name"]. "</td>"; with echo "<td align='left'><a onClick="$('#contactName').val('Contacts Name');"> " . $row["name"]. "</a></td>"; and it should do what you want.

Hope this helps.

sir there is error in your following codes

echo "<td align='left'><a onClick="$('#contactName').val('Contacts Name');"> " . $row["name"]. "</a></td>";

Please modify

What is the error?

Also where is says "Contacts Name" put "$row['name']" as it will be what is displayed in the textbox.