我的 php 代码有问题。问题是过滤指定的 WHERE 子句,但也吐出一些错误,第三条记录应该消失。这是代码:
<body>
<?php
$username="USERNAME";
$password="PASSWORD";
$database="DATABASE";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM searchacts";
$result=mysql_query($query);
$num=mysql_numrows($result);
$result = mysql_query("SELECT * FROM searchacts
WHERE category='Party Bands'");
mysql_close();
?>
<?php
$i=0;
while ($i < $num) {
$image=mysql_result($result,$i,"image");
$name=mysql_result($result,$i,"name");
$category=mysql_result($result,$i,"category");
$description=mysql_result($result,$i,"description");
$stamps=mysql_result($result,$i,"stamps");
$stickmen=mysql_result($result,$i,"stickmen");
$price=mysql_result($result,$i,"price");
$view=mysql_result($result,$i,"view");
$actpagelink=mysql_result($result,$i,"actpagelink");
?>
<a href="<?php echo $actpagelink; ?>" class="searchitem">
<div class="searchimage"><img src="<?php echo $image; ?>"/></div>
<div class="searchtext">
<div class="searchname"><?php echo $name; ?></div>
<div class="searchcategory"><?php echo $category; ?></div>
<div class="searchdescription"><?php echo $description; ?></div>
</div>
<div class="searchstamps"><img src="<?php echo $stamps; ?>" /></div>
<div class="searchstickmen"><img src="<?php echo $stickmen; ?>" /></div>
<div class="searchprice"><span class="pricefrom">from</span><?php echo $price; ?></div>
<div class="searchview"><img src="<?php echo $view; ?>" /></div>
</a>
<?php
$i++;
}
?>
</body>
它可能非常简单,这是错误:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 3 in /home/enterta1/public_html/searchtestingv1.php on line 31
持续多行