Announcement

Collapse
No announcement yet.

Retrieve data from a database mysql using php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieve data from a database mysql using php

    Hello,
    PHP IS NEW TO ME..... I GOT STUCK INTO A PROBLEM....AND I AM NOT GETTING THAT....PLEASE HELP ME,,,,,
    I AM WRITING MY CODES HERE...
    I WANT THE USER TO ENTER ITS Emp_code IN THE TEXTBOX, AND WHEN HE CLICK ON THE BUTTON "RETRIEVE RECORD", THEN THE REPLY SHOULD BE THAT PARTICULAR RECORD....
    PLZ CHECK OUT THE ERRORS,,,,AND LET ME KNOW WHAT TO ADD...?

    <html>
    <head>
    <title>
    Retrieve Record
    </title>
    </head>
    <body bgcolor = '#E3E4FA'>
    <br></br>
    <br></br>
    <br><center>Enter Employee code:&#160;&#160;&#160;
    <input type = "text" name = "T12" size = "10">
    </center></br>
    <br><center><input type="button" value="RETRIEVE Record" name = "retrieve"OnClick ="display_fell_details('".$result"')">
    </center></br>
    <br><center><FORM METHOD="LINK" ACTION="index.php">
    <INPUT TYPE="submit" VALUE="Home">
    </FORM>
    </center></br>

    </body>
    <?php

    if(isset($_POST['retrieve']))
    {
    include 'config.php';
    include 'opendb.php';

    $Emp_code = mysql_real_escape_string($_POST['T12']);

    $result = mysql_query("SELECT * FROM emp_master where Emp_code= '" . $Emp_code . "'");
    echo "<table border='1'align='center'>
    <tr>
    <th>Emp_code</th>
    <th>Name</th>
    <th>Age</th>
    <th>Gender</th>
    <th>Address</th>
    <th>Email_ID</th>
    <th>Mobile_no</th>
    <th>Basic_Salary</th>
    <th>DA</th>
    <th>HRA</th>
    <th>Canteen</th>
    </tr>";
    while($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['Emp_code'] . "</td>";
    echo "<td>" . $row['Name'] . "</td>";
    echo "<td>" . $row['Age'] . "</td>";
    echo "<td>" . $row['Gender'] . "</td>";
    echo "<td>" . $row['Address'] . "</td>";
    echo "<td>" . $row['Email_ID'] . "</td>";
    echo "<td>" . $row['Mobile_no'] . "</td>";
    echo "<td>" . $row['Basic_Salary'] . "</td>";
    echo "<td>" . $row['DA'] . "</td>";
    echo "<td>" . $row['HRA'] . "</td>";
    echo "<td>" . $row['Canteen'] . "</td>";
    echo "</tr>";
    }
    echo "</table>";
    include 'closedb.php';
    }
    ?>
    </html>


    THANK YOU FOR DEVOTING YOUR TIME...
Working...
X