The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Trouble with While()
I have a script with the following code because I couldn't get a while loop to work...
Code:
$timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-1)'; construct_newsdays(); $timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-1) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-2)'; construct_newsdays(); $timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-2) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-3)'; construct_newsdays(); $timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-3) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-4)'; construct_newsdays(); $timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-4) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-5)'; construct_newsdays(); $timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-5) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-6)'; construct_newsdays(); $timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-6) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-7)'; construct_newsdays(); $timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()-7) AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-8)'; construct_newsdays(); Code:
$counter = "0"; while ($counter<=7) { $timespan = 'thread.dateline<UNIX_TIMESTAMP(CURDATE()' . $counter . ') AND thread.dateline>UNIX_TIMESTAMP(CURDATE()-' . $counter-1 . ')'; construct_newsdays(); } |
#2
|
|||
|
|||
A for loop is preferable when you know how many iterations you need.
PHP Code:
|
#3
|
||||
|
||||
Thanks. I'll try it out later this week (Getting late now, don't want to start coding tonight and go back to work tomorrow).
|
#4
|
|||
|
|||
This should be correct:
PHP Code:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|