Help I am trying to make a Edit form

Codes here !

Moderators: macek, egami, gesf

pietercdevries
New php-forum User
New php-forum User
Posts: 5
Joined: Tue Feb 18, 2014 2:38 pm

Help I am trying to make a Edit form

Postby pietercdevries » Tue Feb 18, 2014 2:50 pm

My html code but saved as Modyfyitems.php

Code: Select all

<?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

Code: Select all

<?
$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'");
$test = 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 hid. 8)
For some reason when I hid the search button it doesn't load anything it just reloads the page. :help:
I am new to php but have programming experience in vb.net :oops:
Attachments
Screen Shot 2014-02-18 at 2.46.21 PM.png
Php MyAdmin/ the Database
Screen Shot 2014-02-18 at 2.46.21 PM.png (116.03 KiB) Viewed 154 times
Screen Shot 2014-02-18 at 2.46.08 PM.png
Screenshot of the form
Screen Shot 2014-02-18 at 2.46.08 PM.png (66.35 KiB) Viewed 154 times

sevened7
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Feb 17, 2014 3:53 am

Re: Help I am trying to make a Edit form

Postby sevened7 » Wed Feb 19, 2014 5:50 am

Hi this is the correct way:

Code: Select all

<?php
    $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'");
   
     if (!$result)
          {
          die("Error: Data not found..");
          }
         
    if(mysql_num_rows($result)>0)
    {
        $Barcode = mysql_result($result,0,'Barcode');
             $Sponsor = mysql_result($result,0,'Sponsor');
             $DateReceived =mysql_result($result,0,'DateReceived');
             $Container =mysql_result($result,0,'Container');
             $Pallet = mysql_result($result,0,'Pallet');
             $Amount = mysql_result($result,0,'Amount');
             $Description =mysql_result($result,0,'Description');
             $Remarks = mysql_result($result,0,'Remarks');
             $Location = mysql_result($result,0,'Location');
       
   
    }
   
    mysql_close($conn);
    ?>



Return to “mySQL & php coding”

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron