diff --git a/developer_apps.php b/developer_apps.php index f042b12..561685f 100644 --- a/developer_apps.php +++ b/developer_apps.php @@ -143,6 +143,25 @@ $resultApps = $conn->query($sqlApps);

...

+ prepare($tagSql); + $tagStmt->bind_param('i', $app['id']); + $tagStmt->execute(); + $tagResult = $tagStmt->get_result(); + $tags = []; + while ($tag = $tagResult->fetch_assoc()) { + $tags[] = htmlspecialchars($tag['name']); + } + $tagStmt->close(); + + // 获取应用适用平台 + $platforms = json_decode($app['platforms'], true); + + echo '

标签: '. implode(', ', $tags) . '

'; + echo '

平台: '. implode(', ', $platforms) . '

'; + ?>

评分: /5 diff --git a/index.php b/index.php index 6ca3deb..98ced7b 100644 --- a/index.php +++ b/index.php @@ -177,7 +177,7 @@ $announcement = $announcementResult && $announcementResult->num_rows > 0 ? $anno // 基于标签推荐应用 if (!empty($tagIds)) { $placeholders = implode(',', array_fill(0, count($tagIds), '?')); - $recommendSql = "SELECT a.id, a.name, a.description, a.age_rating, AVG(r.rating) as avg_rating + $recommendSql = "SELECT a.id, a.name, a.description, a.age_rating, a.platforms, AVG(r.rating) as avg_rating FROM apps a LEFT JOIN reviews r ON a.id = r.app_id JOIN app_tags at ON a.id = at.app_id @@ -213,6 +213,23 @@ $announcement = $announcementResult && $announcementResult->num_rows > 0 ? $anno echo '

'; echo '
'. htmlspecialchars($row['name']) . '
'; echo '

'. substr(htmlspecialchars($row['description']), 0, 100) . '...

'; + // 获取应用标签 + $tagSql = "SELECT t.name FROM tags t JOIN app_tags at ON t.id = at.tag_id WHERE at.app_id = ?"; + $tagStmt = $conn->prepare($tagSql); + $tagStmt->bind_param('i', $row['id']); + $tagStmt->execute(); + $tagResult = $tagStmt->get_result(); + $tags = []; + while ($tag = $tagResult->fetch_assoc()) { + $tags[] = htmlspecialchars($tag['name']); + } + $tagStmt->close(); + + // 获取应用适用平台 + $platforms = json_decode($row['platforms'], true); + if (!is_array($platforms)) $platforms = []; + echo '

标签: '. implode(', ', $tags) . '

'; + echo '

平台: '. implode(', ', $platforms) . '

'; echo '

评分: '. round($row['avg_rating'] ?? 0, 1) . '/5

'; echo '查看详情'; echo ''; @@ -231,7 +248,7 @@ $announcement = $announcementResult && $announcementResult->num_rows > 0 ? $anno num_rows > 0 ? $anno echo '
'; echo '
'. $row['name'] . '
'; echo '

'. substr($row['description'], 0, 100) . '...

'; + + // 获取应用标签 + $tagSql = "SELECT t.name FROM tags t JOIN app_tags at ON t.id = at.tag_id WHERE at.app_id = ?"; + $tagStmt = $conn->prepare($tagSql); + $tagStmt->bind_param('i', $row['id']); + $tagStmt->execute(); + $tagResult = $tagStmt->get_result(); + $tags = []; + while ($tag = $tagResult->fetch_assoc()) { + $tags[] = htmlspecialchars($tag['name']); + } + $tagStmt->close(); + + // 获取应用适用平台 + $platforms = json_decode($row['platforms'], true); + if (!is_array($platforms)) $platforms = []; + echo '

标签: '. implode(', ', $tags) . '

'; + echo '

平台: '. implode(', ', $platforms) . '

'; echo '

评分: '. round($row['avg_rating'], 1) . '/5

'; echo '查看详情'; echo '
'; diff --git a/tags.php b/tags.php index 8e206e0..cd79ba0 100644 --- a/tags.php +++ b/tags.php @@ -11,7 +11,7 @@ $search = isset($_GET['search']) ? $_GET['search'] : ''; $limit = isset($_GET['limit']) ? intval($_GET['limit']) : 12; $offset = isset($_GET['page']) ? (intval($_GET['page']) - 1) * $limit : 0; -$sql = "SELECT apps.id, apps.name, apps.description, apps.age_rating, AVG(reviews.rating) as avg_rating +$sql = "SELECT apps.id, apps.name, apps.description, apps.age_rating, apps.platforms, AVG(reviews.rating) as avg_rating FROM apps LEFT JOIN reviews ON apps.id = reviews.app_id "; @@ -142,7 +142,27 @@ $tagResult = $conn->query("SELECT id, name FROM tags ORDER BY name");

...

-

评分: /5

+ prepare($tagSql); + $tagStmt->bind_param('i', $row['id']); + $tagStmt->execute(); + $tagResult = $tagStmt->get_result(); + $tags = []; + while ($tag = $tagResult->fetch_assoc()) { + $tags[] = htmlspecialchars($tag['name']); + } + $tagStmt->close(); + + // 获取应用适用平台 + $platforms = json_decode($row['platforms'], true); + echo ' 标签: '. implode(', ', $tags) . '
'; + $platforms = $platforms ?? []; + echo ' 平台: '. implode(', ', $platforms) . '
'; + echo ' 评分: '. round($row['avg_rating'], 1) . '/5
'; + echo ''; + ?> 查看详情