Help plz (again)!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

Help plz (again)!

Post by DynamiteHost »

You people have been great over the last couple of days (especially hob_goblin). Now I need some more code :D

Code: Select all

if (between $today-7 and $today) {
stuff here
}

else {
nothing
 }
Problem is, It would have to read from a mysql table instead of doing the IF.... I think 8O


Hope you aren't confused like me :lol:
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

Post by DynamiteHost »

I've just been thinking and I may have come up with a solution to my problem :lol:

Just wondering is this the best way and would it work?

Code: Select all

mysql_query = select * from table etc

if ($tableinfo >= $today-7 && $tableinfo <= $today) &#123;
stuff here
&#125;
else &#123;
other stuff
&#125;
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Yes it would and that's probably the only code you could use
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

DynamiteHost wrote:I've just been thinking and I may have come up with a solution to my problem :lol:

Just wondering is this the best way and would it work?

Code: Select all

mysql_query = select * from table etc

if ($tableinfo >= $today-7 && $tableinfo <= $today) &#123;
stuff here
&#125;
else &#123;
other stuff
&#125;

Code: Select all

mysql_query = select * from table etc 

if (($tableinfo >= $today-7) && ($tableinfo <= $today)) &#123; 
stuff here 
&#125; 
else &#123; 
other stuff 
&#125;
Last edited by phice on Tue Sep 17, 2002 11:23 am, edited 1 time in total.
Image Image
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Code: Select all

$qry = mysql_query("select * from table")
$data = mysql_fetch_assoc($qry);
$tableinfo = $data&#1111;'day']; // or whatever the column is named
$today = date("d");
if(($today-7) < 0)&#123;
$week = 0;
&#125; else &#123;
$week = $today-7;
&#125;

if (($tableinfo >= $week) && ($tableinfo <= $today)) &#123; 
//stuff
&#125; 
else &#123; 
//other stuff 
&#125;
you know, something like that.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

DynamiteHost: What are you trying to do exactly?
Post Reply