Search code examples
phphtmlformshtmlfill

Getting php value in html


I am trying to display the name retrieved from Database in html file . Referred couple of blogs, still I am not able to display the value

<?php
$result=mysql_query("SELECT * from `Data`  where Emp_Id = $EmpID")
$info = mysql_fetch_array( $result );
$Emp_ID=$info['Emp_ID'];
<html><head>
<body>
<input  name="emp_number" value=<?php echo $Emp_ID?>/>
<input name='emp_name' value="<?php echo (isset($Emp_ID) ? htmlspecialchars($Emp_ID) : ''); ?>" />
<input name='emp_name'<?php echo (isset($Emp_Name)) ? ('value = "'.$Emp_Name.'"') : "value = \"\""; ?>/>

</body></head></html>
?>

Tried three ways, but none of them worked.


Solution

  • You should use a template system. Beside of that try this:

    <?php
    $result=mysql_query("SELECT * from `Data`  where Emp_Id = $EmpID")
    $info = mysql_fetch_array( $result );
    $Emp_ID=$info['Emp_ID'];
    ?>
    
    <html>
    <body>
    
    <input  name="emp_number" value=<?php echo $Emp_ID; ?>/>
    <input name='emp_name' value="<?php echo (isset($Emp_ID) ? htmlspecialchars($Emp_ID) : ''); ?>" />
    <input name='emp_name'<?php echo (isset($Emp_ID)) ? ('value = "'.$Emp_ID.'"') : "value = \"\""; ?>/>
    
    </body>
    </html>