Dear Experts,

I have following codes

$sql = "SELECT * from contacts order by name" ;
$select = mysqli_query($con,$sql);
$row=mysqli_num_rows($select);
//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>
       </table>      

and Edit.php has this data

<?php
    require_once("connect.php");
        $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'];
                  }
                 }else{
              echo "no data found";
          }
?>

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

[IMG]http://i41.tinypic.com/2qdmo3m.jpg[/IMG]

Please help

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

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js" /></script>
    </head>
    <body>
        <p>
            Name: <input type="text" id="contactName"/>
            <input type="button" value="Click Me" onClick="$('#contactName').val('Contacts Name');" />
        </p>
    </body>
</html>

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.

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.