Jump to content

Editing record by way of hidden variable


ender

Recommended Posts

I have an inventory DB that I have built. You can go to it at [a href=\"http://71.197.44.48/frame.php\" target=\"_blank\"]http://71.197.44.48/frame.php[/a]

the user name is ryan the password is temp123 so you can look at it and see whats going on. You can get to where i want to edit by doing a query by school.

 

Here is the code where it defines the hidden variable:

 

<?PHP
//$db = mysql_connect('localhost','root','') or die("Couldn't connect to the database.");
mysql_select_db('inventorydb') or die("Couldn't select the database");
if ($campus != "") {
$result = mysql_query("SELECT * FROM inventory WHERE campus = '$campus' ORDER BY bisdnumber asc");

}
else {
$result = mysql_query("select * from inventory where bisdnumber = '$numberdata' or xpressnumber = '$numberdata' or servicetag = '$numberdata'");

}

while ($row = mysql_fetch_array($result)) {
echo "
<center>
<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 width=95%><tr align=center bgcolor=lightsteelblue>
<th><font face=tahoma size=2>BISD#:</font></font></th>
<th><font face=tahoma size=2>Product Type:</font></th>
<th><font face=tahoma size=2>Product Model:</font></th>
<th><font face=tahoma size=2>Product Brand:</font></th>
<th><font face=tahoma size=2>Service Tag#:</font></th>
<th><font face=tahoma size=2>Express#:</font></th>
<th><font face=tahoma size=2>Campus:</font></th>
<th><font face=tahoma size=2>Room#:</font></th>
<th><font face=tahoma size=2>Modified By:</font></th>
<th><font face=tahoma size=2>Last Modified:</font></th>
<th><font face=tahoma size=2>Action</font></th>
</tr>
<br>
<tr align=center bgcolor=gainsboro>
<td><font face=tahoma size=2>$row[bisdnumber]</font></td>
<td><font face=tahoma size=2>$row[producttype]</font></td>
<td><font face=tahoma size=2>$row[productmodel]</font></td>
<td><font face=tahoma size=2>$row[productbrand]</font></td>
<td><font face=tahoma size=2>$row[servicetag]</font></td>
<td><font face=tahoma size=2>$row[xpressnumber]</font></td>
<td><font face=tahoma size=2>$row[campus]</font></td>
<td><font face=tahoma size=2>$row[room]</font></td>
<td><font face=tahoma size=2>$row[modifiedby]</font></td>
<td><font face=tahoma size=2>$row[lastmodified]</font></td>
<td><font face=tahoma size=2><form action='editrecord.php'><input type='hidden' name='inventory_id' value='$inventory_id'><input type='submit' value='Edit'>

</tr>
</table>
</center> ";

}

mysql_free_result($result);

?>

 

 

 

and, here is the code of the edit function, which doesnt work for some reason. I want it to pull the record up in a table prefilled out with the info currently entered, but that can be changed to what it needs to be changed to:

 

<?PHP
$db = mysql_connect('localhost','root','') or die("Couldn't connect to the database.");
mysql_select_db('inventorydb') or die("Couldn't select the database");
$result = mysql_query("SELECT * FROM inventory '$inventory_id'");
while ($row = mysql_fetch_array($result)) {
echo "

<html>
<body>
<form action="addrecord.php">
<TABLE BORDER CELLPADDING=3 CELLSPACING=0>
<tr align=center>
<td>BISD Number:</td>
<td><input type="text" name="bisdnumber" value=echo $bisdnumber size="10"></td>

</tr>
<tr align=center>
<td>Serial Number:</td>
<td><input type="text" name="serialnumber" size="15"></td>
</tr>
<tr align=center>
<td>Product Type:</td>

<td><select name="producttype">
<option value="desktop">Desktop
<option value="laptop">Laptop
<option value="printer">Printer
<option value="palm">Palm
<option value="other">Other
</tr>
<tr align=center>
<td>Product Model:
<td><select name="productmodel">
<option value="optiplexgx260">Optiplex GX260
<option value="optiplexgx240">Optiplex GX240
<option value="inspiron8200">Insprion 8200
<option value="gatewaytower">Gateway Tower
<option value="other">Other
</select>

</tr>
<tr align=center>
<td>Product Brand:</td>
<td><select name="productbrand">
<option value="dell">Dell
<option value="gateway">Gateway
<option value="hp">HP
<option value="compaq">Compaq
<option value="lexmark">Lexmark
</select>
</td></tr>
<tr align=center>
<td>ServiceTag#:</td>
<td><input type="text" name="servicetag"size="10"></td>
</tr>

<tr align=center>
<td>ExpressServiceTag#:</td>
<td><input type="text" name="xpressnumber"size=15></td>
</tr>
<tr align=center>
<td>PO#:</td>
<td><input type'text' name="ponumber"size=20></td>
</tr>
<tr align=center>
<td>PO Date:</td>
<td><input type'text' name="podate"size=10></td>
</tr>
<tr align=center>
<td>Warranty:</td>

<td><input type'text' name="warranty"size=20></td>
</tr>
<tr align=center>
<td>Campus:</td>
<td><select name="campus">
<option value="Burleson High School">Burleson High School
<option value="Crossroads High School">Crossroads High School
<option value="Kerr Middle School">Kerr Middle School
<option value="Hughes Middle School">Hughes Middle School
<option value="Academy Elementary School">Academy Elementary School
<option value="Bransom Elementary School">Bransom Elementary School
<option value="Frazier Elementary School">Frazier Elementary School
<option value="Mound Elementary School ">Mound Elementary School
<option value="Norwood Elementary School">Norwood Elementary School
<option value="Stribling Elementary School">Stribling Elementary School
<option value="Taylor Elementary School">Taylor Elementary School

</select>
</td></tr>
<tr align=center>
<td>Room:</td>
<td><input type="text" name="roomnumber"size="3"></td>
<br>

</table><td><input type="submit" value="Submit"></td>
</form>
</body>
}
mysql_free_result($result);

?>

 

im still real new to this, if you couldnt tell, so any help would be appriciated. thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.