我正在构建一个网站 ( which you will be able to find here ),并在此网站上有一个类别列表。
该页面上的每个类别都链接到我的数据库中的一个项目。单击后会显示更多内容。
我在同一个数据库中有一个单独的数据库表单,称为apps(而不是mobi)。在其中我有一个可用的应用程序列表,但有些应用程序适用于选定的设备。
例如,某些应用程序链接到 google play,只能在 Android 设备上显示,因为在其他设备(例如 ios)上显示这些应用程序可能被视为毫无意义。
在 iPhone 和 Android 上显示 iPad 应用程序也是如此,因为这些应用程序可能被视为毫无意义。
该设备保存在我的应用程序数据库中的“设备”字段下,并且具有以下类别之一:iPhone、iPad 或 android,
我想要的是在我的索引页面上显示一个类别,与其他类别一起显示“应用程序下载”。单击后,它仅显示可用的相关应用程序,就像我网站上当前的促销 Activity 一样。
但我只希望链接位于以下设备之一上时显示:iPod touch、iPhone、iPad mini、iPad、android,因为这些是我目前拥有内容的唯一设备。例如。如果您在黑莓或 Windows 8 甚至 Firefox 手机上查看,则此类别将不会显示。
请问有人可以告诉我该怎么做吗?
谢谢。
我的索引页代码是:
<?PHP
include_once('include/connection.php');
include_once('include/article.php');
$category = new category;
$articles = $category->fetch_all();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Xclo.mobi</title>
<link type="text/css" rel="stylesheet" href="other.css" />
<link rel="apple-touch-icon" href="homescreen.png" />
<link href="startup.png" rel="apple-touch-startup-image" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34172259-1']);
_gaq.push(['_setDomainName', 'xclo.co.uk']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<?php include_once('header.php'); ?>
<div id="content">
<?php foreach ($articles as $article) { ?>
<ul class="pageitem"><li class="button">
<a href="list.php?id=<?php echo $article['promo_cat']; ?>">
<input type="submit" name="Submit" value="<?php echo $article['promo_cat']; ?>"/>
</a></li></ul>
<?php } ?>
</div>
<br><center>
<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-eu.amazon-...d9-6cf16307e855"> </SCRIPT> <NOSCRIPT><A HREF="http://ws-eu.amazon-...t">Amazon.co.uk Widgets</A></NOSCRIPT></center>
<?php include_once('footer.php'); ?>
</body>
</html>
请帮忙。谢谢。
最佳答案
已排序。
使用此代码:
<?php
$ua=$_SERVER['HTTP_USER_AGENT'];
switch(true) {
case stripos($ua,'android') :
$device = 'android'; break;
case stripos($ua,'ipad') :
$device = 'ipad'; break;
case stripos($ua,'iphone') :
$device = 'iphone'; break;
}
?>
<ul class="pageitem"><li class="button android"><input name="Submit" value="App Downloads" onclick="window.location='apps.php?id=<?php echo $device; ?>' " type="submit" /></li></ul>
请1up。谢谢。
关于php - 要显示的设备特定内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18607440/