Forum Moderators: coopster
<?php
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$term = $_POST['term'];
$sql = mysql_query("select * from Inventory where assettag = '$term' ");
while ($row = mysql_fetch_array($sql)){
echo '<br/> SerialNumber: '.$row['SerialNumber'];
echo '<br/> ComputerName: '.$row['ComputerName'];
echo '<br/><br/>';
}
?>
<form id="FormName" action="updated.php" method="post" name="FormName">
<table width="448" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="150" align="right"><label for="ComputerName">Computer Name</label></td>
<td><input name="ComputerNamenew" maxlength="" type="text" value="<?php echo $ComputerName ?>"></td>
</tr>
<tr>
<td width="150" align="right"><label for="SerialNumber">Serial Number</label></td>
<td><input name="SerialNumbernew" maxlength="" type="text" value="<?php echo $SerialNumber ?>"></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="" type="submit" value="Update"></td>
</tr>
</table>
</form>
The only problem I'm having is on my update page.
if I could figure out the text boxes and have the mysql data show up in the boxes.
<td><input name="ComputerNamenew" maxlength="" type="text" value="<?php echo trim($row['ComputerName']) ?>"></td>
</tr>
<tr>
<td width="150" align="right"><label for="SerialNumber">Serial Number</label></td>
<td><input name="SerialNumbernew" maxlength="" type="text" value="<?php echo trim($row['SerialNumber']) ?>"></td>
$SerialNumber= trim($row['SerialNumber']);
$ComputerName = trim($row['ComputerName']);
<?php
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$term = $_POST['term'];
$ComputerNamenew = ($_POST["ComputerName"]));
$SerialNumbernew = ($_POST["SerialNumber"]));
$updated="UPDATE Inventory SET ComputerName = '$ComputerNamenew', WHERE ID = '$term'";
if($updated){
echo("<br>Input data is succeed");
} else{
echo("<br>Input data is fail");
}
//if($rsUpdate) { echo "Successfully updated"; } else { die('Invalid query: '.mysql_error()); }
?>
<?php
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$term = $_POST['term'];
$sql = mysql_query("select * from Inventory where assettag = '$term' ");
while ($row = mysql_fetch_array($sql)){
$ComputerName = $row['ComputerName'];
$SerialNumber = $row['SerialNumber'];
}
?>
<form id="FormName" action="updated.php" method="post" name="FormName">
<table width="448" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="150" align="right"><label for="ComputerName">Computer Name</label></td>
<td><input name="ComputerNamenew" maxlength="" type="text" value="<?php echo $ComputerName ?>"></td>
</tr>
<tr>
<td width="150" align="right"><label for="SerialNumber">Serial Number</label></td>
<td><input name="SerialNumbernew" maxlength="" type="text" value="<?php echo $SerialNumber ?>"></td>
</tr>
<tr>
<td width="150" align="right"><label for="AssetTag">Asset Tag</label></td>
<td><input name="AssetTagnew" maxlength="" type="text" value="<?php echo $AssetTag ?>"></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="" type="submit" value="Update"></td>
</tr>
</table>
</form>