Hey guys,
I'm having a little problem with displaying database entries and was wondering if anybody knew what was going wrong. Heres the run down on how the page works:
search.php - The records are displayed by this page along with an edit link next to each record. When the user clicks one of the links, the update page is called.
update.php - This window displays the record information (depending on which one the user clicked) in input boxes. Then the user can change the current info and click update to save the changes.
Right now everything is working perfectly but sometimes the info that should be displayed in update.php is cut short. For example: item name is "Pentium III 600" and only "Pentium" gets diaplayed. Right now this problem is only occuring with the itemName and description records.
As always, any help is greatly appreciated and thanks in advance. Here is my code for those two pages:
SEARCH.PHP
<?
include("header.inc");
include("menu.inc");
include("details.inc");
?>
<TR ALIGN="CENTER">
<TD><H2><CENTER>Display results</CENTER></H2><P>
</TD>
</TR>
<TR ALIGN="CENTER">
<TD>
<?
$searching=$_POST['searching'];
?>
<form name="frmCheck" action="<?php echo $PHP_SELF; ?>" method="post">
<?
include("title.inc");
if (isset($_POST['btnSearch'])) {
if($searching == "") {
printf("Please select a search criteria");
}
elseif ($searching != "") {
if ($searching == "serNum") {
$search=$_POST['serial'];
$query="SELECT * FROM assets WHERE serialNum='" . $search . "'";
$result=mysql_query($query);
}
elseif ($searching == "assNum") {
$search=$_POST['asset'];
$query="SELECT * FROM assets WHERE assetNum='" . $search . "'";
$result=mysql_query($query);
}
elseif ($searching == "locate") {
$search=$_POST['location'];
$query="SELECT * FROM assets WHERE location='" . $search . "'";
$result=mysql_query($query);
if ($search == "Display All") {
$query="SELECT * FROM assets ORDER BY location ASC";
$result=mysql_query($query);
}
}
}
}
While ($rs = mysql_fetch_array($result)) {
print ("<TR ALIGN=CENTER><TD><A HREF=update.php?id=".$rs['id'].">Edit</A></TD><TD>" . $rs['itemName'] . "</TD><TD>" . $rs['serialNum'] . "</TD><TD>" . $rs['assetNum'] . "</TD><TD>" . $rs['location'] . "</TD><TD>" . $rs['description'] . "</TD><TD>" . $rs['entryDate'] . "</TD><TD>" . $rs['warranty'] . "</TD></TR>");}
?>
</TABLE>
</TD>
</TR>
<?
include("footer.inc");
?>
UPDATE.PHP
<?
include("header.inc");
include("menu.inc");
include("details.inc")
?>
<TR ALIGN="CENTER">
<TD><CENTER><H2>Update Database</H2></CENTER><P></TD>
</TR>
<?
$asset = $_POST['asset'];
$name = $_POST['name'];
$location = $_POST['location'];
$description = $_POST['description'];
$warranty = $_POST['warranty'];
$serial = $_POST['serial'];
if(isset($_GET['id'])){
$id=$_GET['id'];
}else{
$id = $_POST['id'];
}
$query="SELECT * FROM assets WHERE id=".$id;
$result=mysql_query($query);
$rs= mysql_fetch_array($result);
if(isset($_POST['btnDelete'])) {
$query="DELETE FROM assets WHERE id=".$id;
mysql_query($query) or die (mysql_error());
?>
<TR ALIGN="CENTER"><TD>Record has been Deleted</TD></TR>
<?
}
if(isset($_POST['btnUpdate'])) {
$query = "UPDATE assets SET serialNum = '".$serial."', assetNum = '".$asset."', itemName = '".$name."',location = '".$location."', description = '".$description."',warranty = '".$warranty."' WHERE id = ".$id;
mysql_query($query) or die (mysql_error());
?>
<TR ALIGN="CENTER"><TD>Record is Updated</TD></TR>
<?
}
?>
<form method="post" action="<?php echo $PHP_SELF; ?>">
<TR ALIGN="CENTER">
<TD>
<TABLE BORDER=1 WIDTH=40% ALIGN="CENTER">
<TR ALIGN=CENTER>
<TD><B>Item Name</B></TD>
<TD><Input type="text" name="name" size="20" value=<? echo $rs['itemName'] ?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Serial Number</B></TD>
<TD><Input type="text" name="serial" size="20" value=<? echo $rs['serialNum'] ?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Asset Number</B></TD>
<TD><Input type="text" name="asset" size="20" value=<? echo $rs['assetNum'] ?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Location</B></TD><TD>
<?
$location_array = array("Baie Verte", "Botwood", "Bishop Falls", "Buchans", "Carmanville", "Centreville", "Change Islands", "Fogo Island", "Gambo", "Gander", "Gaultois", "Glenwood", "Glovertown", "Grand Falls", "Greenspond", "HarbourBreton", "Hare Bay", "Harry's Harbour", "Hermitage", "King's Point", "LaScie", "Lewisporte", "Lumsden", "Musgrave Harbour", "Norris Arm", "Point Leamington", "Robert's Arm", "Seal Cove", "Springdale", "St. Alban's", "Summerford", "Twillingate", "Wesleyville");
echo "<SELECT NAME=location>";
foreach($location_array as $value){
echo "<OPTION VALUE=".$value;
if($rs['location'] == $value)
echo " SELECTED";
echo ">".$value."</OPTION>";
}
echo "</SELECT>";
?>
</TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Description</B></TD>
<TD><Input type="text" name="description" size="20" value=<? echo $rs['description'] ?>></TD>
</TR>
<TR ALIGN=CENTER>
<TD><B>Warranty</B></TD>
<TD><Input type="text" name="warranty" size="20" value=<? echo $rs['warranty'] ?>></TD>
</TiR>
</TABLE>
<BR><CENTER>
<input type="Submit" name="btnUpdate" Value="Update Record">
<input type="Submit" name="btnDelete" Value="Delete Record">
</FORM></CENTER>
</TD>
</TR>
<?
include("footer.inc");
?>