Jump to content


Editing record by way of hidden variable

  • Please log in to reply
1 reply to this topic

#1 ender

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 27 December 2005 - 10:35 PM

I have an inventory DB that I have built. You can go to it at [a href=\"\" target=\"_blank\"][/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:

//$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 "
<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 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'>

</center> ";




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:

$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 "

<form action="addrecord.php">
<tr align=center>
<td>BISD Number:</td>
<td><input type="text" name="bisdnumber" value=echo $bisdnumber size="10"></td>

<tr align=center>
<td>Serial Number:</td>
<td><input type="text" name="serialnumber" size="15"></td>
<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 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

<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
<tr align=center>
<td><input type="text" name="servicetag"size="10"></td>

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

<td><input type'text' name="warranty"size=20></td>
<tr align=center>
<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

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

</table><td><input type="submit" value="Submit"></td>


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

#2 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 December 2005 - 12:25 AM

See cross-post on [a href=\"http://www.mysqlfreaks.com/forums/index.php?showtopic=8884\" target=\"_blank\"]MySQL Freaks[/a] for responses.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users