first thread i post here. I have been searching here for answers and almost always got them. But this one is a slightly different.
I have this php code snippet
<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>";
}
?>
It’s a little messy ,i just don’t know how to add code snippets.
I have done some debugging and got that the 1st line (the line of the for) is the prob, yet I can’t find the problem.
(i replaced $var with 1 and it still didn’t help).
Thank you.
You seem to have forgotten curly braces {} for the if/else statements.
EDIT: Try changing:
<? } ?>to<? }just beforefor($i=0;$i<$var;$i++) {(You missed the php
<?starting tag for the for loop.)