我试图做一个网站,当你点击应用程序它打开它,它现在工作,但打开每一个应用程序,显然我不想要。PHP - 虽然循环查询
我相信我需要把foreach loop so for every application it puts a different
$ appLocation`放入?
这对我来说只是第一个项目,所以也许如果有人能指出我正确的方向。
<?php
$appQuery = "SELECT app_name, app_location, app_status, app_image FROM applications";
$select_posts = mysqli_query($conn, $appQuery);
if ($result = mysqli_query($conn, $appQuery)) {
/* fetch associative array */
while ($row = mysqli_fetch_assoc($result)) {
$appName = $row['app_name']; // List Application Name
$appLocation = $row['app_location']; // List Application Location
$appStatus = $row['app_status']; // List Application Status - 1 = Enabled/0 = Disabled
$appImage = $row['app_image']; // List Application Image Locations
?>
<!-- Tile with image container -->
<div class="tile">
<div class="tile-content">
<div class="image-container">
<form method="post">
<div class="frame">
<button name="appButton"><img src="<?php echo $appImage ?>"></button>
</div>
</form>
<?php
if (isset($_POST['appButton'])) {
exec("start $appLocation");
}
?>
</div>
</div>
</div>
<?php
}
?>
首先 - 不要运行该查询两次,去掉'$ select_posts = mysqli_query($康恩,$ appQuery);'并作为按钮都命名为相同的点击其中任何一个将触发所有应用程序启动 – RamRaider