Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why isnt it this code doing it right?

Status
Not open for further replies.

unborn

Programmer
Joined
Jun 26, 2002
Messages
362
Location
US
<?
$posts = file(&quot;config.txt&quot;);
$postcount = count($posts);
$postinfo = explode(&quot;:&quot;,$posts[0]);
$pages = $postinfo[1];
$totalposts = $postinfo[0];
if ($startcounter > &quot;-2&quot;) $check=&quot;yes&quot;;
echo &quot;posts: $postcount <br> page: $pages <br> total: $totalposts<br> start: $startcount<br> end: $endcount <br>check: $check <br><br>&quot;;

if ($postcount==0) echo &quot;No news is available!&quot;;
else
{
if (empty($startcount))
{
for($i=1; $i < $pages + 1; $i++)
{
if (!empty($posts[$i]))
{
//&quot;/home/error-pr/public_html/test/news/$posts[$i]&quot;
include trim($posts[$i]); echo &quot;<br><br><br>&quot;;
}
else
{
exit;
}
}

$startcount = $pages+1;
$endcount = $startcount+$pages-1;
echo &quot;<a href='news.php?startcount=$startcount&endcount=$endcount'>next</a>&quot;;
}
else
{
for($x=$startcount; $x <= $endcount; $x++)
{
if (!empty($posts[$x]))
{
include trim($posts[$x]); echo &quot;<br><br><br>&quot;;
}
else
{
$xstart = $startcount-$pages;
$xend = $endcount-$pages;
echo &quot;<a href='news.php?startcount=$xstart&endcount=$xend'>back</a>&quot;;
exit;
}
}
$xstart = $startcount-$pages;
$xend = $endcount-$pages;
if ($check=&quot;yes&quot;)
{
$startcount = $endcount+1;
$endcount = $startcount+$pages-1;
echo &quot;<a href='news.php?startcount=$xstart&endcount=$xend'>back</a> + <a href='news.php?startcount=$startcount&endcount=$endcount'>next</a>&quot;;
}
else
{
$startcount = $endcount+1;
$endcount = $startcount+$pages-1;
echo &quot;<a href='news.php?startcount=$startcount&endcount=$endcount'>next</a>&quot;;
}

}
}
?>




its supposed to make it so the first page after it has been press back to.. form the next page that it wont have the back button leading it into the nothingness... i was thinking i should do it off the startcount or endcount and i have... and say the startcount is 1 and i do a check if it is <=1 and it will turn out false.. theni can crack it up to <=5 and it still sats its false... maybe someoen can look over he code and point out what im doing wrong :/ thanks!

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
I haven't study your code too much, but I think the problem will be in:
Code:
because this will everytime be true since it is not comparison but assigning the value to the variable. Try it so:
[code]if ($check==&quot;yes&quot;)

I have made many and many mistakes like this when I made some c++ apps and it caused the application crash at most of time since I wanted to test the pointer value for NULL and I assigned the value of NULL to it instead :-)
 
gizmicek is right:
Assignments in PHP are made with [/b]=[/b].
Comparisons for equality use the [/b]==[/b] operator.

Assignments of a simple value is always successful and returns TRUE.
 
ya ive tried == ive tried <= and >= for some reason its picking it up as true r false for all of it... before i used numbers but it wasnt working so i figured i would try a word bleh tis a little fustrating hehe :D thanks though for trying.

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
well i got it... just so you all know. i changed the whole check thing... instead of checking the $startcount and $endcount i decided what happens if i test the $xend against 0 (0 is what xend is on the first page) and it worked.. it was so bothering me i had dreams about it hahaha and the dream just came back to me and i tried it .. wooo rocked :P thanks for help.

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top