我的类型链接的PHP代码:
<?php
$dbhost = 'localhost';
$dbuser ='root';
$dbpass = '';
$dbname = 'moviefone';
$con = mysql_connect($dbhost,$dbuser, $dbpass);
mysql_select_db($dbname, $con);
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (isset($_GET['genre'])){
switch ($_GET['genre']){
case 'action':
break;
case 'art_and_experimental':
break;
case 'comedy':
break;
//etc
}
}
$resultcat=mysql_query("SELECT * FROM movies WHERE lang='hindi'");
$info=array();
while ($row = mysql_fetch_array($data)){
$info[]=$row;
}
?>
当我在www.example.com/movies页面时,它会显示电影中的所有结果,但我想在用户点击类型链接时过滤结果,它应显示来自hindi电影过滤器的所有结果在同一页上。
这是我的html流派导航:
<ul class="snav">
<li><a href="?genre=action">Action</a></li>
<li><a href="?genre=art_and_experimental">Art and Experimental</a></li>
<li><a href="?genre=comedy">Comedy</a></li>
<li><a href="?genre=crime_and_mystery">Crime and Mystery</a></li>
</ul>
</li>
</ul>
这里我希望获取的内容显示在:
<div class="sub-column1">
<a href="#"><img src="<?php echo $info[0]['images'];?>" class="new-img2" /></a>
<a href="#" class="img_titles">chennai express</a>
</div>
我无法让它发挥作用。我想做什么?
答案 0 :(得分:0)
if (isset($_GET['genre'])){
$genre = $_GET['genre'];
$resultcat=mysql_query("SELECT * FROM movies WHERE genre='$genre'");
} else {
$resultcat=mysql_query("SELECT * FROM movies");
}
$info=array();
while ($row = mysql_fetch_array($resultcat)){
$info[]=$row;
}