我在这里发布的第一个线程。我一直在这里寻找答案,几乎总能得到答案。但这一个略有不同。我有这个 php 代码片段
<tr>
<td>
<?php if (mysql_numrows($sqlstr) != 0) { //if there are records found
while ($row = mysql_fetch_array($sqlstr)) { //do while there are rows
if($English==1)
$Title=$row["sSubCatEng"];
else
$Title=$row["sSubCat"];
echo $Title;
}
} ?>
</td>
</tr>
<?php
$NumOfItems= 9; //Number of items per page.
$ItemsCount=count($ItemPartID); //number of items in ItemPartID array
$Page = $_GET["Page"]; //puts the var in a local one
if(($NumOfItems*$Page) > $ItemsCount) // if it is the last page
{
$StopFor = $ItemsCount % $NumOfItems; //stop when you modulo
$j = ($NumOfItems*($Page - 1));
$indexFor = $StopFor;
}
else
{
$StopFor = $NumOfItems * $Page;
$j =($NumOfItems*($Page - 1));
$indexFor = $StopFor - $j;
}
?>
<tr>
<?php if($English==0){ ?>
<td dir="rtl" align="center" colspan="3">
<?php echo $ItemsCount; ?> <?php echo $Title; ?> <?php echo $NumOfItems; ?>
<?php }else { ?>
<td align="center" colspan="3">
Currently there are <?php echo $ItemsCount." ".$Title; ?> in the catalog.Only <?php echo $NumOfItems; ?> are displayed on each page.
<? } ?>
<? for($i=0;$i<$var;$i++) {
echo "<td style='width:30px;height:30px;border-color:black;border-style:solid;border- width:1px;background-color: lightgray;font-weight: bold;text-align: center;";
if($Page==($i+1))
echo "color:red;";
echo "' onmouseover=\"this.style.cursor = 'pointer';\" onmousemove=\"this.style.backgroundColor = 'red';this.style.color='white';\" onmouseout=\"this.style.backgroundColor='lightgray';";
if($Page==($i+1))
echo "this.style.color='red';";
else
echo "this.style.color='black';";
echo "\" onClick='window.location=\"Catalog.php?Cat={$Category}&Page=".($i+1)."&SubCat= {$SubCat}&lang={$Lang}\"' >".($i+1);
echo "</td>";
}
?>
有点乱,我只是不知道如何添加代码片段。我进行了一些调试,发现第一行(for 行)是问题所在,但我找不到问题所在。(我用 1 替换了 $var ,但它仍然没有帮助)。谢谢你。