it is very difficult to see which braces are opening things, which ones are closing things, and which ones are in the wrong place.
My advice is to start braces on a new line and indent - that way you can clearly see what's going on:
instead of
for($i = 1; $i <= $numofpages; $i++){
if($i == $page)
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF&page=$i\">$i</a> ");
if(($totalrows % $limit) != 0){
if($i == $page)
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF&page=$i\">$i</a> ");
i would do:
for($i = 1; $i <= $numofpages; $i++)
{
if($i == $page)
echo($i." ");
}
else
{
echo("<a href=\"$PHP_SELF&page=$i\">$i</a> ");
if(($totalrows % $limit) != 0)
{
if($i == $page)
echo($i." ");
}
else
{
echo("<a href=\"$PHP_SELF&page=$i\">$i</a> ");
etc etc
Makes it much easier to see where one starts if it's on the next line than if it's hidden at the end of a line.
and dont forget that if your if only contains one line then you dont need the braces:
if(this==that)
{
then do this;
}
next do this;
// is the same as
if(this==that)
then do this;
next do this;