Well guys, I am storing data in the mysql which when extracted gives this -
[PHP]Array
(
[0] => Array
(
[id] => 26
[date] => 2007-11-01
[time] => 16:01:00
[duration] => 08:00:00
[access] => ouvert
[description] => something goes here
)
[1] => Array
(
[id] => 17
[date] => 2007-11-03
[time] => 13:05:00
[duration] => 00:00:00
[access] => ouvert
[description] => something goes here.
)
[2] => Array
(
[id] => 18
[date] => 2007-11-03
[time] => 16:06:00
[duration] => 00:10:00
[access] => restreint
[description] => something goes here.
)
)[/PHP]
As you guys can see, data is related to a date and time, in each case.
Now, I have a start date and an end date. Say 2007-10-25 and 2007-11-06. I also have a function that gives the number of dates between the two dates.
The problem starts here. I want to print a different row for each date (between and including the start and end dates), and then depending on if data present against a given date, print it, or leave the row empty.
Wondering, what would be the smartest way of doing this...
Idea guys? Thanks for your time. :)
************************************************** ******
I just found a solution to the first part -
[PHP]for ($i=0;$i<=$diff;$i++) {
echo date("Y-n-d", mktime(0, 0, 0, $du2, $du3 + $i, (int)$du1))."<hr />";
}[/PHP]
is giving me the dates as I want :)
1 1774
Well guys
Here's where I'm now. It's a working solution. if someone is looking for something similar, feel free to pick it up. However, not sure this is the fastest solution. Experts are requested to give their views.
[PHP]foreach ($result as $rex) {
$dateArr[] = $rex['date'];
}
for ($i=0;$i<=$diff;$i++) {
$chkDate = date("Y-n-d", mktime(0, 0, 0, $du2, $du3 + $i, (int)$du1));
echo $chkDate." => ";
if (isset($result)) {
foreach ($dateArr as $k=>$v) {
if ($chkDate == $v) {
echo $result[$k]['description'];
}
}
echo "<hr />";
} else {
echo NO_RDV;
}
}[/PHP]
where, $result holds the array of the first post. $du2 is month, $du3 is day and $du1 is year. $diff is the number of dates between the two dates.
Best.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dean |
last post by:
I am a developer who works with MS SQL Server a lot, but I'm far from
an expert. I am revamping an appointment scheduling system that
allows for appointments to reoccur daily, weekly, monthly and yearly.
Currently, I am saving the appointment date as the initial appointment
date. Then when I want to check for appointments, my stored proc...
|
by: p175 |
last post by:
People,
I have an ESE 8.2.2 database running on win2k server . I need to
do some system testing that requires I reset the dates back a couple of
years then progressivily move it forward to current date.
The last time I tried this the database got very upset and the date
functions such as DAYOFWEEK_ISO, YEAR, WEEK, QUARTER etc got all...
|
by: Thelma Lubkin |
last post by:
I have a form/subform with the common one-to-many relationship.
The form allows user to display records and move to other records
via the selector, to add,delete, and edit them, with the related
records displayed in the subform going along for the ride.
The parent form's recordset has fields
string integer
COLORNAME CLASSSIZE and a...
|
by: Dennis D. |
last post by:
Hello:
Been working on this way too long.
DateDiff returns a Long. : Totally counter-intuitive.
Subtracting: 0400 - 0345 returns -15 : Wrong, should be +15?
Subtracting 02:00 - 00:15 with an interval of minutes returns 105 which is 2
hours minus 15 minutes, not the expected 01:45 or at least 45
Simply, there are two textboxes. Both...
|
by: clare at snyder.on.ca |
last post by:
I have a SQL query I need to design to select name and email addresses
for policies that are due and not renewed in a given time period. The
problem is, the database keeps the information for every renewal in
the history of the policyholder.
The information is in 2 tables, policy and customer, which share the
custid data. The polno changes...
| |
by: HLCruz via AccessMonster.com |
last post by:
I am working with a database that has client information separated in to 4
related tables - tFolder, tAddress, tEmail, tPhone number. In addition there
are related tables tGifts and tCalls. The database has roughly 22,000
records but should only have around 6,000. The remaining records are
duplicates, but in many cases the correct data for...
|
by: krishnakant Mane |
last post by:
hello all.
thanks for the help and for pointing me to the proper url for wxpython
related issues.
I am so happy that I now have a very easy gui library that can do
practically every thing with such ease (no flames intended but I was
never at so much ease with java swing ).
I however have a problem with dates.
I am tired searching for some...
|
by: Timothy.Rybak |
last post by:
I need help designing a database that keeps up with a point system we
have here at work. I'll tell you what I know.
First, I have a list of all the employee names for a table.
Second, for various reasons that I don't want to go in to, people can
earn points, in half point increments, toward a reward.
Now for the tricky part. The...
|
by: srusskinyon |
last post by:
I need some help getting unique records from our database! I work for
a small non-profit homeless shelter. We keep track of guest
information as well as what services we have offered for statistical
purposes.
I've been using
Here's the situation:
I have two main tables:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |