Question

My html code but saved as Modyfyitems.php

<?include 'Login/login_check.php';?>
<?include 'inc/Application.php';?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<style type="text/css">
body {
   background-color: #284489;
   text-shadow: 0px 0px #FFFFFF;
   color: #FFFFFF;
}
form1 {
   background-color: #FFFFFF
}
</style>
<link rel="stylesheet" type="text/css" media="all" href="css/jsDatePick_ltr.min.css" />

 <script type="text/javascript" src="js/jsDatePick.min.1.3.js"></script>

 <script type="text/javascript">
   window.onload = function(){
      new JsDatePick({
         useMode:2,
         target:"datereceived",
         dateFormat:"%d-%M-%Y"
      });
   };
</script>

</head>

<body>
<h2>&nbsp;</h2>
<form id="form1" name="form1" aling="center" method="post">
  <div align="center">
    <table width="393" border="0">
      <tr>
        <td><div align="center">
          <h2><span style="text-align: left; color: #FFFFFF;">LAC Product Registery</span></h2>
        </div></td>
      </tr>
    </table>
    <p>
      <input type="button" name="button4" id="button4" onClick="location.href='Menu.php'" value="Menu">
    </p>
  </div>
  <div align="center" style="background-color: #FFFFFF; color: #000000;">
    <table width="827" border="0" align="center">
      <tr bgcolor="#FDFDFD">
        <td width="501"><h3>Modify Items</h3>
          <p>Enter Code
            <input name="barcode" type="text" autofocus required="required" id="barcode" form="form1">
            <input type="submit" name="search" id="search" onClick="location.href='Actions/loaditem.php'" value="Search">
          </p>
          <table width="500" border="0" cellpadding="10" cellspacing="1">
          <tr>
            <td width="141" bgcolor="#E8F1FC">Sponsor</td>
            <td width="316" bgcolor="#E8F1FC"><?include 'Actions/loadLists/sponsor.php';?></td>
          </tr>
          <tr>
            <td bgcolor="#f1f4f9">Date Received</td>
            <td bgcolor="#f1f4f9"><input type="datetime" name="datereceived" value="<? echo $DateReceived; ?>" id="datereceived" placeholder="17-FEB-2014"></td>
          </tr>
          <tr>
            <td bgcolor="#E8F1FC"><strong>Code</strong></td>
            <td bgcolor="#E8F1FC">&nbsp;</td>
          </tr>
          <tr>
            <td bgcolor="#F1F4F9"><ul>
              <li> Container</li>
            </ul></td>
            <td bgcolor="#F1F4F9"><input name="container" type="number" value="<? echo $Container; ?>" id="container" placeholder="0152"></td>
          </tr>
          <tr>
            <td bgcolor="#E8F1FC"><ul>
              <li>Pallet</li>
            </ul></td>
            <td bgcolor="#E8F1FC"><input name="pallet" type="number" value="<? echo $Pallet; ?>" id="number5" placeholder="0028"></td>
          </tr>
          <tr>
            <td bgcolor="#F1F4F9"><ul>
              <li>Amount</li>
            </ul></td>
            <td bgcolor="#F1F4F9"><input name="amount" type="number" id="number6" value="<? echo $Amount; ?>" placeholder="0002"></td>
          </tr>
          <tr>
            <td bgcolor="#E8F1FC">Description</td>
            <td bgcolor="#E8F1FC"><?include 'Actions/loadLists/descriptions.php';?></td>
          </tr>
          <tr>
            <td bgcolor="#F1F4F9">Remarks</td>
            <td bgcolor="#F1F4F9"><textarea name="remarks" id="remarks"><? echo $Remarks; ?></textarea></td>
          </tr>
          <tr>
            <td bgcolor="#E8F1FC">Location</td>
            <td bgcolor="#E8F1FC"><?include 'Actions/loadLists/locations.php';?></td>
          </tr>
          <tr>
            <td height="18">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
        <td width="316" valign="top" style="text-align: left"><p><br>
        </p>
          <p>          Documents</p>
        <p>&nbsp; </p></td>
      </tr>
    </table>
  </div>
  <table width="383" border="0" align="center">
    <tr>
      <td width="377" style="text-align: center"><input type="button" name="button" id="button" value="Save">
        ...
          <input type="button" name="button6" id="button6" onClick="location.href='Menu.php'" value="Cancel">
          ...
          <input type="button" name="button2" id="button2" value="Delete">
         ...
      <input type="button" name="button3" id="button3" value="Print Barcode"> </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

Here is my PHP script

<?
$conn = mysql_connect('localhost', 'root', 'root');
    if (!$conn)
    {
    die('Could not connect: ' . mysql_error());
   }
   mysql_select_db("LAC", $conn);

   $Barcode =$_REQUEST['barcode'];

$result = mysql_query("SELECT * FROM Lists WHERE Barcode  = '$Barcode'");
$row = mysql_fetch_array($result);
if (!$result)
      {
      die("Error: Data not found..");
      }
         $Barcode = $row['Barcode'];
         $Sponsor = $row['Sponsor'];
         $DateReceived = $row['DateReceived'];
         $Container = $row['Container'];
         $Pallet = $row['Pallet'];
         $Amount = $row['Amount'];
         $Description = $row['Description'];
         $Remarks = $row['Remarks'];
         $Location = $row['Location'];

mysql_close($conn);
?>

So Basically I am trying to load all the text boxes and drop down boxes from the database when the correct barcode is entered and the search button is hit. For some reason when I hit the search button it doesn't load anything it just reloads the page. I am new to php but have programming experience in vb.net

Was it helpful?

Solution

I think your are initializing variables after fetching values from the database in PHP script. so the scope of those variable is only withing that file. So, I guess if you include that file in modifyitem.php, this would work.

thank you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top