FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to loop through the dates?
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Return to the default flat view Create a new topic Submit Reply
How to loop through the dates? [message #186117] Sun, 15 June 2014 12:11 Go to previous message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma:
Senior Member
add to buddy list
ignore all messages by this user
http://mroldies.net/radio/tracker2.php


I've got my report generator almost completed.
I only need to know how I can loop through the dates.
In BASIC, this is no big deal.

As a synopsis,
The table "tracker" is consulted for data.
Data is ordered by date.
Data is now transferred to the array $master.
From $master, data is outputted as desired.
In this case, each song played on a given date is listed.




$query = "SELECT * FROM tracker ORDER BY date";
$result = mysqli_query($con, $query);
@$num_results = mysqli_num_rows($result);

/*Loop through each row and display records */
for($i=0; $i<$num_results; $i++) {
$row = mysqli_fetch_assoc($result);

$master[$i]['date']=$row['date'];
$master[$i]['songID']=$row['songID'];
$master[$i]['track']=$row['track'];
$master[$i]['artist']=$row['artist'];
$master[$i]['hits']=$row['hits'];
}

for($i=0;$i<$num_results;$i++){

print $master[$i]['date'];
echo "<br>";
}
echo "<table border=\"1\">";

$newdate=$master[0]['date'];

$ct=0;
print "<tr><td>".$master[$ct]['date']."</td></tr>";
while ($ct<$num_results){

if ($master[$ct]['date']==$newdate) {
print "<tr><td>".$master[$ct]['track']."</td></tr>";
}

$ct++;
}

echo "</table>";


mysqli_close($con);
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: What is the purpose of "&" in this code?
Next Topic: why is it always an endless loop?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 12 05:32:47 EST 2017

Total time taken to generate the page: 0.00861 seconds