我正在尝试显示数据库中具有相同类别的所有结果。
我已经设法从数据库中打印了一行,只是想知道我如何为其余的做这件事?
这是我的代码
<?php
$catagory=$_GET["q"];
$con = mysql_connect("localhost","cl49-XXX","XXX");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
@mysql_select_db("cl49-vogalcms", $con)or die( "Unable to select database");
$result=mysql_query("SELECT * FROM products WHERE catagory = '$catagory' ")or die('You need enter a catagoryE ' );
$row = mysql_fetch_array($result);
$prodname=$row['prodname'];
$prodID=$row['prodID'];
echo"Catagory: $catagory <br /> ID $prodID<br /> name $prodname";
if ($swt==0) {$swt=1;} else {$swt=0;}
?>