我試圖做一個網站,當你點擊應用程序它打開它,它現在工作,但打開每一個應用程序,顯然我不想要。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