<body onLoad="displayResult()">
<table align="center">
<tr>
<td>
<?php $query2="SELECT * FROM upload1 WHERE NAME='xmlsample1.xml'";
$result1=mysql_query($query2);
$row = mysql_fetch_array($result1);
?>
<form action="">
<textarea id="validxml" rows="50" cols="100">
<?php echo $row['CONTENT']; ?>
</textarea>
<br><br>
<input type="button" value="Verify XML" onClick="validateXML()" />
</form>
</td>
</tr>
</table>
</body>
答案 0 :(得分:1)
答案 1 :(得分:1)
connect.php
应保存在单独的安全网页上。
<?php
function db(){
return new mysqli('host', 'username', 'password', 'database');
}
?>
现在在您的另一页上:
<?php
include 'connect.php'; $db = db();
$sq = $db->query("SELECT * FROM upload1 WHERE name='xmlsample1.xml'"); $ta = '';
if($sq->num_rows > 0){
while($row = $sq->fetch_object()){
$ta .= "<textarea class='validxml' name='{$row->name}'>{$row->content}</textarea>";
}
}
$sq->free(); $db->close();
?>
现在只需将$ta
回显到您的HTML中即可。当然,除非您希望用户能够编辑代码,否则我甚至不会使用<textarea>
来输出代码。