Sounds confusing...^_^
Anyway, running into a problem:
A user will select from a list to modify a record in a database and then taken to a page that allows them to edit it.
The page to allow the editing has this coding:
And when the fields have been edited, it takes you to this page:
The problem is the table : accessory (which needs to be updated) within the database is NOT being updated with the new information (ie if you change the items' name, serial number or user)
Help and TIA
Anyway, running into a problem:
A user will select from a list to modify a record in a database and then taken to a page that allows them to edit it.
The page to allow the editing has this coding:
Code:
<?
if (!$accessId) {
header("Location: [URL unfurl="true"]http://opushi/test2/modacc.php");[/URL]
exit;
} else {
session_start();
}
if ($valid != "yes") {
header("Location: [URL unfurl="true"]http://opushi/test2/admin.php");[/URL]
exit;
} else {
session_register('valid');
}
$db_name = "acess";
$table_name = "accessory";
$connection = @mysql_connect("localhost", "root") or die("Couldn't connect.".mysql_error());
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.".mysql_error());
$sql = "SELECT item, snumber
FROM $table_name
WHERE accessId = \"$accessId\"
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.".mysql_error());
while ($row = mysql_fetch_array($result)) {
$item = $row['item'];
$snumber = $row['snumber'];
$userId = $row['userId'];
}
?>
<HTML>
<HEAD>
<TITLE>Modify Accessory</TITLE>
</HEAD>
<BODY>
<h2><font face="Arial, Helvetica, sans-serif">Modify Accessory</font></h2>
<FORM METHOD="post" ACTION="mod_accessdone.php">
<INPUT TYPE="hidden" name="id" value="<? echo "$id"; ?>">
<table width=50% align=center>
<tr>
<td><font face=arial size=2>Item:</font></td>
<td><input type="text" name="item" value="<? echo "$item"; ?>" size=50 maxlength=75></td>
</tr>
<tr>
<td><font face=arial size=2>Serial Number:</font></td>
<td><input type="text" name="snumber" value="<? echo "$snumber"; ?>" size=50 maxlength=75></td>
</tr>
<tr>
<td><font face="arial" size=2>On Loan to:</font></td>
<td><select name="userId">
<?php
$q="select userId, username from user
order by userId asc";
$r=mysql_query($q) or die(mysql_error().$q);
while($row=mysql_fetch_array($r)) {
echo "<option value=\"".$row["userId"]."\">".$row["username"]."</option>";
}
?>
</select> </td>
</tr>
</table>
<center><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Update Accessory"></center>
</FORM>
</BODY>
</HTML>
And when the fields have been edited, it takes you to this page:
Code:
<?
if (!$item) {
header( "Location: [URL unfurl="true"]http://opushi/test2/modacc.php");[/URL]
exit;
} else {
session_start();
}
if ($valid != "yes") {
header ( "Location: [URL unfurl="true"]http://opushi/test2/admin.php");[/URL]
exit;
} else {
session_register('valid');
}
$db_name = "acess";
$table_name = "accessory";
$connection = @mysql_connect("localhost","root") or die ("Couldn't connect.".mysql_error());
$db = @mysql_select_db($db_name, $connection) or die ("Couldn't select database.".mysql_error());
$sql = "UPDATE accessory
SET
item = \"$item\",
snumber = \"$snumber\",
userId = \"$userId\"
WHERE accessId = \"$accessId\"
";
$result = @mysql_query($sql,$connection) or die ("Couldn't execut query.".mysql_error());
?>
<html>
<head>
<title> Modify Accessory Complete</title>
</head>
<body>
<div align="center"><font face="Arial, Helvetica, sans-serif"><b>Modified Accessory</b></font><font size="2" face="Arial, Helvetica, sans-serif"><b>
</b><br>
The following accessory has been changed </font><br>
<table width=50% align=center>
<tr>
<td width="19%"><font face="Arial, Helvetica, sans-serif" size="2">Item:</font></td>
<td width="81%"><font face="Arial, Helvetica, sans-serif" size="2">
<? echo "$item"; ?>
</font></td>
<tr>
<td width="19%"><font face="Arial, Helvetica, sans-serif" size="2">Serial
Number:</font></td>
<td width="81%"><font face="Arial, Helvetica, sans-serif" size="2">
<? echo "$snumber"; ?>
</font></td>
</tr>
<tr>
<td width="19%"><font face="Arial, Helvetica, sans-serif" size="2">On Loan
to:</font></td>
<td width="81%"> <font face="Arial, Helvetica, sans-serif" size="2">
<? echo "$userId"; ?>
</font></td>
</tr>
</table>
<font face="arial" size=2><a href="admin.php">Back to the Admin Menu</a></font>
</div>
</body>
</html>
The problem is the table : accessory (which needs to be updated) within the database is NOT being updated with the new information (ie if you change the items' name, serial number or user)
Help and TIA