我在這裏發佈的第一個線程。我一直在尋找答案,幾乎總是得到答案。但是這個有點不同。 我有這個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,但它仍然沒有幫助)。 謝謝。
'$意外end'通常意味着你忘記關閉'}'for循環,但是,這段代碼有點混亂,但最終還是很好的。這是你在那裏的_exact_代碼嗎? – Wrikken