Update database help

i have set up a search of my database and now i want wen i click a result it to take me to a page were i can have the user edit the information this is my search code:

<?php require('check_login.php'); echo "Logout"; echo " "; echo "Home"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-… Search

Search

' />
<?php $k = $_GET['k']; $terms = explode(" ", $k); $query = "SELECT * FROM patients WHERE ";

foreach ($terms as $each){
$i++;
if ($i == 1)
$query .= "Keyword LIKE ‘%$each%’ ";
else
$query .= "OR Keyword LIKE ‘%$each%’ ";
}

// connect
mysql_connect(“localhost”, “root”, “password”);
mysql_select_db(“hospital_patients”)…

$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if ($numrows > 0){

while ($row = mysql_fetch_assoc($query)){
$id = $row[‘id’];
$name = $row[‘First_Name’];
$lname = $row[‘Last_Name’];

echo "

$name, $lname

";

}

}
else
echo “No results found for “$k””;

// disconnect
mysql_close();
?>

Hi cmb,

Just replace this particular line:

[php]echo "

$name, $lname

[/php]

with

[php]echo “

<a href=‘modify.php?id=’” . $id . “>” . $name . " " . $lname . “

”;[/php]

And in your modify.php, get the query string value of id.

thxs it worked perfectly

Sponsor our Newsletter | Privacy Policy | Terms of Service