updating records
Posted: Thu Jun 14, 2007 10:25 am
hi, im having a problem and need some help from you guys, i have this code.
the $ed is getting its value from another page which has this code
now, when i try to move my mouse pointer over the link, it will reflect the eid value...the problem is that, the getting page do not get its value. and also, i was thinking why is it that the if (isset($_POST['submit'])) part of my page is not setting and finishes the code block without doing anything.
thank you.
Code: Select all
<?php
$ed = $_GET['eid'];
if (isset($_POST['submit'])) {
$error = null;
if (empty($_POST['text_edit'])) {
$e = false;
$error = "cannot be blank";
} else {
$e = $_POST['text_edit'];
}
if (!$e) {
$squery = "SELECT RightsDesc FROM hh_Rights WHERE RightsKey='" . $ed . "'";
$sresult = mysql_query($squery) or die(mysql_error());
if ($sresult) {
$query = "UPDATE hh_Rights SET RightsDesc='" . $e . "' WHERE RightsKey='" . $ed . "'";
$result = @mysql_query($query) or die(mysql_error());
if (mysql_affected_rows() == 1) {
echo "nagedit";
} else {
echo "nde nagedit";
}
}
} else {
echo "system error.<br>";
}
}
?>Code: Select all
$query = "SELECT RightsKey, RightsDesc FROM hh_Rights";
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo "
<tr>
<td width='85%'>". $row[1] . "</td>
<td width='15%' align='center'><a href='edit-rights.php?eid=" . $row[0] ."'>Edit</a></td>
</tr>
";
}
}thank you.