Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #13862
| Date | 2014-06-15 20:01 +0200 |
|---|---|
| From | Luuk <luuk@invalid.lan> |
| Newsgroups | comp.lang.php |
| Subject | Re: How to loop through the dates? |
| References | <ywx2wjj7uwar$.105qt7ftnicew$.dlg@40tude.net> <lnklqr$j2v$1@dont-email.me> |
| Message-ID | <2l317b-4cc.ln1@luuk.invalid.lan> (permalink) |
On 15-6-2014 19:40, Denis McMahon wrote: > On Sun, 15 Jun 2014 12:11:01 -0400, richard wrote: > >> Data is ordered by date. > > See, this is where the richard database design starts to bite the richard > arse. > > You are storing dates as a string representation of the date, so your > "order by date" sql clause causes the data to be ordered according to the > string collation for the relevant table. > > If you want the mysql rdbms to sort the data into date sequence, then you > need to store the data as dates. The mysql rdbms sorts dates perfectly. > It also sorts strings perfectly. But to sort dates it needs to know that > they are dates, and you have told it that they are strings. Because you > have told it that they are strings, when you ask it to sort them, it > sorts them as strings. So the sorting rules it applies to a column of > type datetime are different to the sorting rules it applies to a column > of type [var]char. > > supposing you store the strings: > > '06/21/2013', '07/21/12013' and '06/21/2014' > > the sorted sequence will probably[1] be: > > '06/21/2013' > '06/21/2014' > '07/21/2013' > > [1] unless you have a weird collation defined > > Because in most 'western alphabet' character sorting sequences, 6 comes > before 7, and ascii strings are sorted from left to right. > up until here, you did not visit the link to his site, which he gave, and that's why above i see some things dat are not true. The link is showing the date fields in the correct order: 01-06-2014 01-06-2014 01-06-2014 02-06-2014 02-06-2014 02-06-2014 02-06-2014 02-06-2014 02-06-2014 02-06-2014 02-06-2014 02-06-2014 03-06-2014 03-06-2014 03-06-2014 03-06-2014 03-06-2014 03-06-2014 03-06-2014 03-06-2014 03-06-2014 04-06-2014 04-06-2014 04-06-2014 04-06-2014 04-06-2014 04-06-2014 04-06-2014 04-06-2014 04-06-2014 > That aside, you don't seem to have actually described what the problem > that you want fixed is this time, nor have you given examples of (a) what > you expect to happen and (b) what is actually happening, so you'll not be > surprised that we can't diagnose and resolve the issue, and are instead > reduced to identifying, yet again, the generic flaws in your approach to > coding. @richard: it's the link which gave an example, and some people (most of them) do NOT want to follow a link to a website. It's much better to give a short example of what's happening in the message with your problem, than referring to a website. > > Instead of suppressing the error in the call to mysqli_num_rows, you > should first test whether mysqli_query() returned an error flag. You have > been told this several times. > > The mechanisms you're using to loop through the result set and the > resulting array that you create are neither efficient or easy to follow. > > As far as I can see, your code can be replaced with about 12 lines of > competently written php, with an extra 5 lines to add some comprehensive > error reporting and user friendly error handling. >
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to loop through the dates? richard <noreply@example.com> - 2014-06-15 12:11 -0400
Re: How to loop through the dates? Luuk <luuk@invalid.lan> - 2014-06-15 18:38 +0200
Re: How to loop through the dates? Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-15 17:43 +0000
Re: How to loop through the dates? Luuk <luuk@invalid.lan> - 2014-06-15 20:03 +0200
Re: How to loop through the dates? Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-15 17:40 +0000
Re: How to loop through the dates? richard <noreply@example.com> - 2014-06-15 13:59 -0400
Re: How to loop through the dates? Luuk <luuk@invalid.lan> - 2014-06-15 20:27 +0200
Re: How to loop through the dates? Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-15 19:14 +0000
Re: How to loop through the dates? Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-15 21:39 +0000
Re: How to loop through the dates? Arno Welzel <usenet@arnowelzel.de> - 2014-06-17 08:12 +0200
Re: How to loop through the dates? Luuk <luuk@invalid.lan> - 2014-06-15 20:01 +0200
Re: How to loop through the dates? Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-15 19:07 +0000
Re: How to loop through the dates? Luuk <luuk@invalid.lan> - 2014-06-15 21:58 +0200
Re: How to loop through the dates? Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-16 00:55 +0000
Re: How to loop through the dates? richard <noreply@example.com> - 2014-06-16 13:02 -0400
Re: How to loop through the dates? Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-16 17:57 +0000
Re: How to loop through the dates? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-06-15 19:14 -0400
Re: How to loop through the dates? richard <noreply@example.com> - 2014-06-16 12:26 -0400
Re: How to loop through the dates? Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-16 16:39 +0000
Re: How to loop through the dates? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-06-16 14:14 -0400
Re: How to loop through the dates? Arno Welzel <usenet@arnowelzel.de> - 2014-06-17 08:18 +0200
Re: How to loop through the dates? Tim Streater <timstreater@greenbee.net> - 2014-06-15 20:30 +0100
Re: How to loop through the dates? Luuk <luuk@invalid.lan> - 2014-06-15 22:01 +0200
Re: How to loop through the dates? Tim Streater <timstreater@greenbee.net> - 2014-06-15 21:34 +0100
Re: How to loop through the dates? Luuk <luuk@invalid.lan> - 2014-06-15 23:32 +0200
Re: How to loop through the dates? richard <noreply@example.com> - 2014-06-16 12:19 -0400
Re: How to loop through the dates? Norman Peelman <npeelman@cfl.rr.com> - 2014-06-16 20:44 -0400
Re: How to loop through the dates? Norman Peelman <npeelman@cfl.rr.com> - 2014-06-15 20:59 -0400
csiph-web