records are not being updated as well as no error is shown to me............

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • puneetmca
    New Member
    • Jan 2010
    • 15

    records are not being updated as well as no error is shown to me............

    hi...
    i want to update employee's record but its not being updated.....can u help me out....
    no error is shown to me.....




    [code=html]
    <html>
    <body bgcolor="pink">
    <?
    $con=mysql_conn ect("localhost" ,"root","root") ;
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db ("master", $con);
    $result=mysql_q uery("select * from emp_company");
    echo "<table border='3'> <BR><BR><BR><BR >
    <tr>
    <th >Employee Code</th>
    <th>Name</th>
    <th>Company</th>
    <th> Shift</th>
    <th>DOJ</th>
    <th>DOL</th>
    <th> Dept</th>
    <th> Subdept</th>
    <th>ESI Code</th>
    <th>P/F</th>
    <th>Card No.</th>
    <th>Bank A/C No.</th>
    </tr>" ;
    while($row=mysq l_fetch_assoc($ result))
    {
    echo "<tr>";
    echo "<td>" . $row['ecode'] . "</td>";
    echo "<td>" . $row['ename'] . "</td>";
    echo "<td>" . $row['ecom']. "</td>";
    echo "<td>" . $row['eshift'] . "</td>";
    echo "<td>" . $row['edoj'] . "</td>";
    echo "<td>" . $row['edol'] . "</td>";
    echo "<td>" . $row['edpt'] . "</td>";
    echo "<td>" . $row['esubdpt'] . "</td>";
    echo "<td>" . $row['eesicode'] . "</td>";
    echo "<td>" . $row['epf'] . "</td>";
    echo "<td>" . $row['ecardno'] . "</td>";
    echo "<td>" . $row['ebank'] . "</td>";
    echo "</tr>";
    echo '<a href="update.ph p?ecode='.$row['ecode'].' ">Update</a> ' ;
    }
    mysql_close($co n);
    ?>
    </body></html>
    [/code]
    [code=php]
    <?
    mysql_connect(" localhost","roo t","root");
    mysql_select_db ("master");

    // ***** This part will process when you Click on "Submit" button *****
    // Check, if you clicked "Submit" button
    if($_POST['Submit']){

    // Get parameters from form.
    $ecode=$_POST['ecode'];
    $ename=$_POST['ename'];
    $ecom=$_POST['ecom'];
    $eshift=$_POST['eshift'];
    $edoj=$_POST['edoj'];
    $edol=$_POST['edol'];
    $edpt=$_POST['edpt'];
    $esubdpt=$_POST['esubdpt'];
    $eesicode=$_POS T['eesicode'];
    $epf=$_POST['epf'];
    $ecardno=$_POST['ecardno'];
    $ebank=$_POST['ebank'];


    mysql_query("up date emp_company set ecode='$ecode', ename='$ename', ecom='$ecom', eshift='$eshift ',edpt='$edpt', esubdpt='$esubd pt',edoj='$edoj ',edol='$edol', eesicode='$eesi code',epf='$epf ',ecardno='$eca rdno,ebank='$eb ank' where ecode='$ecode'" );

    // Re-direct this page to select.php.
    header("locatio n:select.php");
    exit;
    }
    // ************* End update part *************

    // *** Select data to show on text fields in form. ***

    // Get id parameter (GET method) from select.php
    $ecode=$_GET['ecode'];

    // Get records in all columns from table where column id equal in $id and put it in $result.
    $result=mysql_q uery("select * from emp_company where ecode='$ecode'" );

    // Split records in $result by table rows and put them in $row.
    $row=mysql_fetc h_assoc($result );

    // Close database connection.
    mysql_close();
    ?>

    <!-- END OF PHP CODES AND START HTML TAGS -->

    <html>
    <body>
    <!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
    <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
    <p>code
    <input name="ecode" type="text" id="ecode" value="<? echo $row['ecode']; ?>"/>
    <p>Name :
    <!-- name of this text field is "name" -->
    <input name="ename" type="text" id="ename" value="<? echo $row['ename']; ?>"/>
    <br />
    <p>Company
    <input name="ecom" type="text" id="ecom" value="<? echo $row['ecom']; ?>"/>
    <p>
    <p>shift :
    <!-- name of this text field is "email" -->
    <input name="eshift" type="text" id="eshift" value="<? echo $row['eshift']; ?>"/>
    <br />
    <p>DOJ
    <input name="edoj" type="text" id="edoj" value="<? echo $row['edoj']; ?>"/>
    <p>
    <p>DOL :
    <!-- name of this text field is "tel" -->
    <input name="edol" type="text" id="edol" value="<? echo $row['edol']; ?>"/>
    </p>
    <p>Dept.
    <input name="edpt" type="text" id="edpt" value="<? echo $row['edpt']; ?>"/>
    <p>

    <p>Sub Dept.
    <input name="esubdpt" type="text" id="esubdpt" value="<? echo $row['esubdpt']; ?>"/>
    <p>
    <p>ESICODE
    <input name="eesicode" type="text" id="eesicode" value="<? echo $row['eesicode']; ?>"/>
    <p>
    <p>P/F
    <input name="epf" type="text" id="epf" value="<? echo $row['epf']; ?>"/>
    <p>
    <p>CardNo.
    <input name="ecardno" type="text" id="ecardno" value="<? echo $row['ecardno']; ?>"/>
    <p>
    <p>Bank A/C No.
    <input name="ebank" type="text" id="ebank" value="<? echo $row['ebank']; ?>"/>
    <p>
    <input type="submit" name="Submit" value="Submit" />
    </p>
    </form>
    </body>
    </html>
    [/code]
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Originally posted by puneetmca
    no error is shown to me.....
    That does not surprise me, since you don't even bother to check the result of your UPDATE query before you redirect the page.

    Read this post, specifically the second part regarding the MySQL error messages.

    Comment

    Working...