我正在构建一个网站(which you will be able to find here),并在此网站上列出了类别。
该页面上的每个类别都链接到我的数据库中的项目。然后,点击后会显示更多内容。
我在同一个名为apps(而不是mobi)的数据库中有一个单独的数据库表单。在这里我有一个可用的应用程序列表,但有些应用程序是针对选定的设备。
例如某些应用程序链接到Google Play并且只能在Android设备上显示,因为在其他设备上显示这些应用程序(例如ios)可能会被视为毫无意义。
同样适用于在iPhone和Android上显示iPad应用程序,因为这些可以被视为毫无意义。
该设备保存在我的应用程序数据库的“设备”字段下,并拥有iPhone iPad或Android这些类别中的一个,
我想要的是在我的索引页面上显示一个类别,另一个是“APP DOWNLOADS”。点击后,它只显示相关的应用程序,就像我网站上当前的促销活动一样。
但我只希望链接出现在其中一个设备上: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>
请帮忙。谢谢。
答案 0 :(得分:1)
排序。
使用此代码:
<?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。谢谢。