我想从我的表格中选择包含 2 列的内容:Judul, Isi.
<head><link type="text/css" rel="stylesheet" href="addnewpage.css"/</head>
<body>
<?php
$k = mysqli_connect("localhost", "root", "", "ubm_2015");
$sql = "select * from proses;";
$h = mysqli_query($k, $sql);
$b = mysqli_fetch_array($h);
?>
<div id="box">
<div id="left">
<div id="logo">
<img src="gambar/arg.gif" height="50" width="200"/>
</div>
<div id="menu">
<div class="current">Pages</div>
<a href="contact.html"><div class="menu">Contact</div></a>
<a href="user.html"><div class="menu">User</div></a>
</div>
</div>
<div id="right">
<div id="top">
Welcome, admin
<a href="login.html"><input type="submit" value="log out" /></a>
</div>
<div id="head"><h1>Edit Pages</h1></div>
<div id="form">
<table>
<tr>
<td><label>Judul : </label></td>
<td><input type="text" name="judul" value="<?php echo $b['Judul']; ?>" /></td>
</tr>
<tr>
<td><label>Body : </label></td>
<td><input type="text" name="isi" value="<?php echo $b['Isi']; ?> "/></td>
</tr>
<tr>
<td><label>Bahasa : </label></td>
<td>
<select>
<option value="ind">Indonesia</option>
<option value="eng">English</option>
</select>
</td>
</tr>
<tr>
<td><label>Parent : </label></td>
<td>
<select>
<option value="p">Parent</option>
<option value="sm">Sub-Menu</option>
</select>
</td>
</tr>
</table>
</div>
<div id="button">
<input type="button" value="Send"/>
<a href="page.html"><input type="button" value="Back"/></a>
</div>
</div>
</body>
但是输入框显示<?php echo $b['Isi']; ?>
而不是表格的内容。
注意:
I saved the html code in htdocs folder, which inside the xampp folder.
The format is html.
Database name : ubm_2015
请帮忙。非常感谢。
最佳答案
我假设您正在通过网络服务器访问此文件(不是 file://,而是 http://)。您的网络服务器必须将您的代码作为 PHP 代码处理,而不是 HTML 代码。尝试使用 .php 扩展名。
在您的网络服务器配置中,您将有类似的内容:
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
因此 .php(和类似)文件将作为 PHP 代码进行处理。
关于php - 从 html 执行查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34132266/