Hi, i have implemented a basic searchwhich does display the results, i want to add an edit function button, so that when the user click edit the results are displayed in input boxes so that the content can be edited.
Her is what iv got so far, im new to php:
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myq=$_POST['myq'];
if (isset($_POST['myq'])) {
$myq = mysql_real_escape_string($_POST['myq']);
$result = mysql_query("SELECT * FROM members WHERE Firstname LIKE '%$myq' OR Surname LIKE '%$myq'");
while ($row = mysql_fetch_assoc($result)) {
echo "<p>You searched for: "" . $myq . ""</p>";
echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>First Name</th>";
echo "<td>";
echo $row['Firstname'];
echo "</td>";
echo "<tr><th>Surname</th>";
echo "<td>";
echo $row['Surname'];
echo "</td>";
echo "<tr><th>Username</th>";
echo "<td>";
echo $row['username'];
echo "</td>";
echo "<tr><th>Password</th>";
echo "<td>";
echo $row['password'];
echo "</td>";
echo "<tr><th>Email</th>";
echo "<td>";
echo $row['email'];
echo "</td>";
echo "<tr><th>Level</th>";
echo "<td>";
echo $row['level'];
echo "</td>";
}
}
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
if (mysql_num_rows($result) == 0) {
echo "No records found";
exit;
}
?>