Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-09-2009, 01:09 PM Loop?
Experienced Talker

Posts: 43
Trades: 0
Hi everybody. I keep getting errors when i try to create a loop in php.

PHP Code:
$date=date("d/M/Y");

$sql="SELECT * FROM files WHERE date='".$date."'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

echo 
"Pictures uploaded today:"
echo 
$count
This is my code gives me the result "pictures uploaded today: 3"

So it works fine. But i would like to do so that is shows.

Pictures uploaded today : 3
Pictures uploaded Yesterday: 5
Pictures uploaded today -2: 3
and so on, for a whole week.


So i want this loop to count the pictures uploaded today, and 6 days back. How should that loop looks like?
Sgbirkelund is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-09-2009, 02:40 PM Re: Loop?
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
PHP Code:
$time time();
for(
$i 0$i 7$i++)
{
     
$newTime $time - ($i 24 60 60);
     
$date date('d/M/Y'$newTime);

     
$sql "SELECT * FROM files WHERE date = '$date'";
     
$result mysql_query($sql);
     
$count mysql_num_rows($result);

     echo 
"Pictures uploaded on $date$count <br/>"

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 06-09-2009 at 02:50 PM..
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 06-09-2009, 03:01 PM Re: Loop?
Experienced Talker

Posts: 43
Trades: 0
Thank you very much. It was your trick with adding a day to times i couldnt figure out.

It works. Thanks!!!
Sgbirkelund is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Loop?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11715 seconds with 12 queries