I am trying to load text into a form (textarea) from an existing text file resident on the server. I am having no luck. The code I am using (with variations) is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><title>SVP Data</title>
<link rel="stylesheet" href="main.css"/>
</head>
<body style="background-color:#FFFFFF">
<title>oakhurstsvp.org</title>
<link href="../twoColLiqLtHdr.css" rel="stylesheet" type="text/css" style="background-color:white"/>
<h1><div align="left">
<img src="../images/SVP Header.jpg" width="966" height="158" /> 
</div></h1>
<form>
<textarea id="comments" name="comments" cols="90" rows="5" style="font-size:12pt;border:double;background:#FFC">
<?php
$handle = fopen ("../images/comments.txt", "r+");
$mytextfile = get_file_contents('$handle');
echo $mytextfile
?>
</textarea>
</form>
</body>
</html>

What am I doing wrong?

Recommended Answers

All 2 Replies

//loop through your table like this

<?php
$con = mysqli_connect("localhost","servername","dbn","pwd");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to Database: " . mysqli_connect_error();
  } 
$sql = "SELECT *FROM tbl";

$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {

     // student_detail table
     $mg=$row['mg'];    

            }
    }

    ?>
    <textarea> <?php echo $mg?></textarea> //text display in textarea
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.