RE: [PHP] order by ASC

2010-01-19 Thread Ashley Sheridan
On Tue, 2010-01-19 at 16:16 -0800, Daevid Vincent wrote:

 http://www.webdeveloper.com/forum/showthread.php?t=101174
 
 You could do it like this too...
 
 ORDER BY `rollnumber` + 0 ASC 
 
 And if you just got the data out in mysql (no ORDER BY -- which can be slow
 in mysql), you could use PHP's sort as well...
 
 http://php.net/manual/en/function.natsort.php
 
  -Original Message-
  From: Robert Cummings [mailto:rob...@interjinn.com] 
  Sent: Saturday, January 16, 2010 9:37 PM
  To: John Taylor-Johnston
  Cc: PHP-General
  Subject: Re: [PHP] order by ASC
  
  John Taylor-Johnston wrote:
   Did some googling. This worked:
   ORDER BY CAST(`rollnumber` AS SIGNED)
   
   What is the difference? My problem in the meanwhile must be 
  my version 
   of MySQL?
  
  You could have skipped quotes altogether. The difference is 
  that you are 
  referencing a field name, not a string value.
  
  Cheers,
  Rob.
  -- 
  http://www.interjinn.com
  Application and Templating Framework for PHP
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 


I've always found that ordering is much faster in MySQL than PHP. You
use quite a lot of memory sorting in PHP as well, as you first have to
load the whole result set into an array, which is additional to any
memory used in the result set by PHP and MySQL anyway.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] order by ASC

2010-01-19 Thread Daevid Vincent
http://lmgtfy.com/?q=mysql+order+by+slow
 
it's notoriously slow to use ORDER BY with large tables. Mainly b/c mySQL
has to use a hash/temp table to re-sort AFAIK.
 
I wasn't thinking of sorting the whole set, only the list of numbers as the
OP only talked about sorting a single column...
 
 rollnumber is a varchar(50). I need it to be a text field. ASC does 
 not order the way I want.

 1000
 1001
 998
 999

 I want it to order like this:

 998
 999
 1000
 1001


  _  

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Tuesday, January 19, 2010 4:40 PM
To: Daevid Vincent
Cc: 'PHP-General'
Subject: RE: [PHP] order by ASC


On Tue, 2010-01-19 at 16:16 -0800, Daevid Vincent wrote: 

http://www.webdeveloper.com/forum/showthread.php?t=101174



You could do it like this too...



ORDER BY `rollnumber` + 0 ASC 



And if you just got the data out in mysql (no ORDER BY -- which can be slow

in mysql), you could use PHP's sort as well...



http://php.net/manual/en/function.natsort.php



 -Original Message-

 From: Robert Cummings [mailto:rob...@interjinn.com] 

 Sent: Saturday, January 16, 2010 9:37 PM

 To: John Taylor-Johnston

 Cc: PHP-General

 Subject: Re: [PHP] order by ASC

 

 John Taylor-Johnston wrote:

  Did some googling. This worked:

  ORDER BY CAST(`rollnumber` AS SIGNED)

  

  What is the difference? My problem in the meanwhile must be 

 my version 

  of MySQL?

 

 You could have skipped quotes altogether. The difference is 

 that you are 

 referencing a field name, not a string value.

 

 Cheers,

 Rob.

 -- 

 http://www.interjinn.com

 Application and Templating Framework for PHP

 

 -- 

 PHP General Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php

 






I've always found that ordering is much faster in MySQL than PHP. You use
quite a lot of memory sorting in PHP as well, as you first have to load the
whole result set into an array, which is additional to any memory used in
the result set by PHP and MySQL anyway.


Thanks,
Ash
http://www.ashleysheridan.co.uk






RE: [PHP] order by ASC

2010-01-19 Thread Ashley Sheridan
On Tue, 2010-01-19 at 17:11 -0800, Daevid Vincent wrote:

 http://lmgtfy.com/?q=mysql+order+by+slow
  
 it's notoriously slow to use ORDER BY with large tables. Mainly b/c mySQL
 has to use a hash/temp table to re-sort AFAIK.
  
 I wasn't thinking of sorting the whole set, only the list of numbers as the
 OP only talked about sorting a single column...
  
  rollnumber is a varchar(50). I need it to be a text field. ASC does 
  not order the way I want.
 
  1000
  1001
  998
  999
 
  I want it to order like this:
 
  998
  999
  1000
  1001
 
 
   _  
 
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
 Sent: Tuesday, January 19, 2010 4:40 PM
 To: Daevid Vincent
 Cc: 'PHP-General'
 Subject: RE: [PHP] order by ASC
 
 
 On Tue, 2010-01-19 at 16:16 -0800, Daevid Vincent wrote: 
 
 http://www.webdeveloper.com/forum/showthread.php?t=101174
 
 
 
 You could do it like this too...
 
 
 
 ORDER BY `rollnumber` + 0 ASC 
 
 
 
 And if you just got the data out in mysql (no ORDER BY -- which can be slow
 
 in mysql), you could use PHP's sort as well...
 
 
 
 http://php.net/manual/en/function.natsort.php
 
 
 
  -Original Message-
 
  From: Robert Cummings [mailto:rob...@interjinn.com] 
 
  Sent: Saturday, January 16, 2010 9:37 PM
 
  To: John Taylor-Johnston
 
  Cc: PHP-General
 
  Subject: Re: [PHP] order by ASC
 
  
 
  John Taylor-Johnston wrote:
 
   Did some googling. This worked:
 
   ORDER BY CAST(`rollnumber` AS SIGNED)
 
   
 
   What is the difference? My problem in the meanwhile must be 
 
  my version 
 
   of MySQL?
 
  
 
  You could have skipped quotes altogether. The difference is 
 
  that you are 
 
  referencing a field name, not a string value.
 
  
 
  Cheers,
 
  Rob.
 
  -- 
 
  http://www.interjinn.com
 
  Application and Templating Framework for PHP
 
  
 
  -- 
 
  PHP General Mailing List (http://www.php.net/)
 
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  
 
 
 
 
 
 
 I've always found that ordering is much faster in MySQL than PHP. You use
 quite a lot of memory sorting in PHP as well, as you first have to load the
 whole result set into an array, which is additional to any memory used in
 the result set by PHP and MySQL anyway.
 
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
   
 


I had a look at some of the results from that link to Google, but I
didn't see anything indicating MySQL was slower at ordering than PHP,
only that MySQL has issues ordering very large query sets on queries
that it cannot use an index to order on.

I've tried optimising ordering in both PHP and MySQL, and found that
usually it's best to leave as much to the database as possible, unless
the ordering becomes too complex.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] order by ASC

2010-01-16 Thread Robert Cummings

John Taylor-Johnston wrote:

Ok, I think this is a MySQl question. Take pity on me?

$sql = SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 
'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC;


rollnumber is a varchar(50). I need it to be a text field. ASC does not 
order the way I want.


1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way in PHP?


CAST it to an integer in the ORDER BY clause.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by ASC

2010-01-16 Thread John Taylor-Johnston

It hates me:

SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST(rollnumber AS int)
SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST(`rollnumber` AS int)
SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST('rollnumber' AS int)


You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near 'int) ASC' 
at line 1


I'll keep trying.

Robert Cummings wrote:

CAST it to an integer in the ORDER BY clause.

Cheers,
Rob.

John Taylor-Johnston wrote:

Ok, I think this is a MySQl question. Take pity on me?

$sql = SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 
'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC;


rollnumber is a varchar(50). I need it to be a text field. ASC does 
not order the way I want.


1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way 
in PHP?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by ASC

2010-01-16 Thread John Taylor-Johnston

Did some googling. This worked:
ORDER BY CAST(`rollnumber` AS SIGNED)

What is the difference? My problem in the meanwhile must be my version 
of MySQL?


John Taylor-Johnston wrote:

It hates me:

SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST(rollnumber AS int)
SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST(`rollnumber` AS int)
SELECT * FROM ... WHERE `type` IN ('Member', 'Affiliated', 'Life 
Member') ORDER BY CAST('rollnumber' AS int)


You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right syntax to use 
near 'int) ASC' at line 1


I'll keep trying.

Robert Cummings wrote:

CAST it to an integer in the ORDER BY clause.

Cheers,
Rob.

John Taylor-Johnston wrote:

Ok, I think this is a MySQl question. Take pity on me?

$sql = SELECT * FROM $db.`mailinglist` WHERE `type` IN ('Member', 
'Affiliated', 'Life Member') ORDER BY `rollnumber` ASC;


rollnumber is a varchar(50). I need it to be a text field. ASC does 
not order the way I want.


1000
1001
998
999

I want it to order like this:

998
999
1000
1001

How do I trick it? I cannot think of a way in MySQL. Is there a way 
in PHP?





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by ASC

2010-01-16 Thread Robert Cummings

John Taylor-Johnston wrote:

Did some googling. This worked:
ORDER BY CAST(`rollnumber` AS SIGNED)

What is the difference? My problem in the meanwhile must be my version 
of MySQL?


You could have skipped quotes altogether. The difference is that you are 
referencing a field name, not a string value.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] order by what?

2009-06-11 Thread Jay Blanchard
[snip]
How can order by be forced to order alphabetically and ignore accents
without stripping the accents for printout? This is a problem for both
caps  normal letters.
[/snip]

Definitely an SQL question. What character set are you using in your
database? Is the accent the first character of the string or is this a
multi-byte character? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread PJ
Jay Blanchard wrote:
 [snip]
 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.
 [/snip]

 Definitely an SQL question. What character set are you using in your
 database? Is the accent the first character of the string or is this a
 multi-byte character? 
   
utf8 general
the accents are French - including first character and others in the
words...
e.g. Érable comes up before Autres; and Céréales appears before Café...
I imagine it's a collation (character set) problem. I don't know what to
use to eliminate this problem. Should the collation be latin1 swedish_ci
? I have never received a definitive response even on this list. :-(
And this is an ever recurring problem as I work with several languages
which all have accents...


-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] order by what?

2009-06-11 Thread Jay Blanchard
[snip]
 [snip]
 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.
 [/snip]

 Definitely an SQL question. What character set are you using in your
 database? Is the accent the first character of the string or is this a
 multi-byte character? 
   
utf8 general
the accents are French - including first character and others in the
words...
e.g. Érable comes up before Autres; and Céréales appears before Café...
I imagine it's a collation (character set) problem. I don't know what to
use to eliminate this problem. Should the collation be latin1 swedish_ci
? I have never received a definitive response even on this list. :-(
And this is an ever recurring problem as I work with several languages
which all have accents...
[/snip]

Have you considered asking on the list of the database of your choice? Like the 
MySQL list? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread Robin Vickery
2009/6/11 PJ af.gour...@videotron.ca

 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.


Depends on the database.

If you're using mysql, the order is governed by the collation used. To get
the order you want, you need a case-insensitive and accent-insensitive
collation. Exactly which one you use will depend on the character set that
you're using, but if you're character set is utf8, then the utf8_general_ci
collation should work:

SELECT fieldname FROM tablename ORDER BY fieldname COLLATE utf8_general_ci;

-robin


Re: [PHP] order by what?

2009-06-11 Thread PJ
PJ wrote:
 Jay Blanchard wrote:
   
 [snip]
 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.
 [/snip]

 Definitely an SQL question. What character set are you using in your
 database? Is the accent the first character of the string or is this a
 multi-byte character? 
   
 
 utf8 general
 the accents are French - including first character and others in the
 words...
 e.g. Érable comes up before Autres; and Céréales appears before Café...
 I imagine it's a collation (character set) problem. I don't know what to
 use to eliminate this problem. Should the collation be latin1 swedish_ci
 ? I have never received a definitive response even on this list. :-(
 And this is an ever recurring problem as I work with several languages
 which all have accents...
   
There are some options which all need some sort of adjustment.
If , e.g. É is used in the db instead of Eacute; the output onscreen is
a little black diamond with a quesion mark inside. The order is correct,
but the diamond is not acceptable... obviously, one cannot expect people
to change their browser or whatever adjustments just for my little diamonds.
Again, it probably means changing the collation - but where, in my database?
TIA

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread PJ
Jay Blanchard wrote:
 [snip]
   
 [snip]
 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.
 [/snip]

 Definitely an SQL question. What character set are you using in your
 database? Is the accent the first character of the string or is this a
 multi-byte character? 
   
 
 utf8 general
 the accents are French - including first character and others in the
 words...
 e.g. Érable comes up before Autres; and Céréales appears before Café...
 I imagine it's a collation (character set) problem. I don't know what to
 use to eliminate this problem. Should the collation be latin1 swedish_ci
 ? I have never received a definitive response even on this list. :-(
 And this is an ever recurring problem as I work with several languages
 which all have accents...
 [/snip]

 Have you considered asking on the list of the database of your choice? Like 
 the MySQL list? 

   
They're not as nice as the guys on this list... usually ;-)

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread PJ
Robin Vickery wrote:


 2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca

 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.


 Depends on the database.

 If you're using mysql, the order is governed by the collation used. To
 get the order you want, you need a case-insensitive and
 accent-insensitive collation. Exactly which one you use will depend on
 the character set that you're using, but if you're character set is
 utf8, then the utf8_general_ci collation should work:

 SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
 utf8_general_ci;

 -robin
Nice thought, Robin. My collation is already uft8_general_ci.
Adding that condition to the query changes nothing; and specifying
another collation return a blank or null and the list is not echoed.
Even changing the collation in the db does not change anything. Same
wrong results.
Thanks anyway.

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread Andrew Ballard
On Thu, Jun 11, 2009 at 11:27 AM, PJaf.gour...@videotron.ca wrote:
 Robin Vickery wrote:


 2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca

     How can order by be forced to order alphabetically and ignore accents
     without stripping the accents for printout? This is a problem for both
     caps  normal letters.


 Depends on the database.

 If you're using mysql, the order is governed by the collation used. To
 get the order you want, you need a case-insensitive and
 accent-insensitive collation. Exactly which one you use will depend on
 the character set that you're using, but if you're character set is
 utf8, then the utf8_general_ci collation should work:

 SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
 utf8_general_ci;

 -robin
 Nice thought, Robin. My collation is already uft8_general_ci.
 Adding that condition to the query changes nothing; and specifying
 another collation return a blank or null and the list is not echoed.
 Even changing the collation in the db does not change anything. Same
 wrong results.
 Thanks anyway.

 --
 Hervé Kempf: Pour sauver la plančte, sortez du capitalisme.
 -
 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php



Are you storing the actual characters in the database or are you
storing the HTML entities? It WON'T sort correctly if you are storing
the entities.

Make sure you are storing the actual characters in your database, and
then make sure that you are sending the correct content-type header
when you serve the page. If you try to serve UTF-8 characters but your
server is sending a Content-Type: ISO-8859-1; header, you will get
placeholders in FF for characters that aren't recognized.

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread PJ
Robin Vickery wrote:


 2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca

 How can order by be forced to order alphabetically and ignore accents
 without stripping the accents for printout? This is a problem for both
 caps  normal letters.


 Depends on the database.

 If you're using mysql, the order is governed by the collation used. To
 get the order you want, you need a case-insensitive and
 accent-insensitive collation. Exactly which one you use will depend on
 the character set that you're using, but if you're character set is
 utf8, then the utf8_general_ci collation should work:

 SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
 utf8_general_ci;

 -robin
Obviously there is another solution, albeit rather silly: re-enter all
the fields in alphabetical order with corresponding id fields in
numerical order... great, if you're not going to change the list and if
it's quite short... not too clever, though is it?

-- 
Hervé Kempf: Pour sauver la planète, sortez du capitalisme.
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread Per Jessen
PJ wrote:

 PJ wrote:
 There are some options which all need some sort of adjustment.
 If , e.g. É is used in the db instead of Eacute; the output onscreen
 is a little black diamond with a quesion mark inside. The order is
 correct, but the diamond is not acceptable... obviously, one cannot
 expect people to change their browser or whatever adjustments just for
 my little diamonds. 

Set the correct character set for your output.  It's in the HTTP header. 


/Per

-- 
Per Jessen, Zürich (20.2°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by what?

2009-06-11 Thread Eddie Drapkin
On Thu, Jun 11, 2009 at 11:35 AM, PJ af.gour...@videotron.ca wrote:

 Robin Vickery wrote:
 
 
  2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca
 
  How can order by be forced to order alphabetically and ignore accents
  without stripping the accents for printout? This is a problem for
 both
  caps  normal letters.
 
 
  Depends on the database.
 
  If you're using mysql, the order is governed by the collation used. To
  get the order you want, you need a case-insensitive and
  accent-insensitive collation. Exactly which one you use will depend on
  the character set that you're using, but if you're character set is
  utf8, then the utf8_general_ci collation should work:
 
  SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
  utf8_general_ci;
 
  -robin
 Obviously there is another solution, albeit rather silly: re-enter all
 the fields in alphabetical order with corresponding id fields in
 numerical order... great, if you're not going to change the list and if
 it's quite short... not too clever, though is it?

 --
 Hervé Kempf: Pour sauver la plančte, sortez du capitalisme.
 -
 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


PFT just run a cron job to re--order the table every two minutes.
Easily the best solution.


Re: [PHP] order by what?

2009-06-11 Thread Robin Vickery
2009/6/11 PJ af.gour...@videotron.ca

 Robin Vickery wrote:
 
 
  2009/6/11 PJ af.gour...@videotron.ca mailto:af.gour...@videotron.ca
 
  How can order by be forced to order alphabetically and ignore accents
  without stripping the accents for printout? This is a problem for
 both
  caps  normal letters.
 
 
  Depends on the database.
 
  If you're using mysql, the order is governed by the collation used. To
  get the order you want, you need a case-insensitive and
  accent-insensitive collation. Exactly which one you use will depend on
  the character set that you're using, but if you're character set is
  utf8, then the utf8_general_ci collation should work:
 
  SELECT fieldname FROM tablename ORDER BY fieldname COLLATE
  utf8_general_ci;
 
  -robin
 Nice thought, Robin. My collation is already uft8_general_ci.
 Adding that condition to the query changes nothing; and specifying
 another collation return a blank or null and the list is not echoed.
 Even changing the collation in the db does not change anything. Same
 wrong results.
 Thanks anyway.


Hiyah,

Well the mysql docs confirm that utf8_general_ci is accent-insensitive and
case-insensitive (
http://dev.mysql.com/doc/refman/5.4/en/charset-collation-implementations.html).
Which implies that maybe you don't actually have utf8 text in that field.

If you do a SHOW VARIABLES LIKE 'character_set%'; what do you get for
character_set_client, character_set_results and character_set_connection?

-robin


Re: [PHP] Order directory output

2008-02-14 Thread Richard Lynch
opendir/readdir does not promise to deliver the files in any
particular order, no matter what it seems to do on any given day...

Put them in an array and sort() if it's a small list of files.

Or use exec and ls -als or somesuch for a large list of files.

Or...

glob *might* be documented to do things in a certain order, but I
doubt it.

On Fri, February 8, 2008 4:44 pm, Pastor Steve wrote:
 Hi, thanks for all your help today.

 I have the following code and I am trying to order the output.
 Currently it
 seems really random. Can anyone point me in the right direction?

 ?php

 $dir = content/current/breaking_news/;

 // set pattern
 $pattern = .txt*|.TXT*;

 // open directory and parse file list
 if (is_dir($dir))
 {
 if ($dh = opendir($dir))
 {

 //This is the div that contains the wrap around for the breaking news
 section.
 echo 
 div class=\spstory\ style=\font-family: Times New Roman,
 Times,
 serif; font-size: 12px; width: 290px;\
 div style=\width: 285px; background-color: #CC; padding:
 3px;\
 span class=\NormalHeadRed\Breaking News/span
 br /Please check here often for breaking news stories.
 /div
 p /
 span class=\NomalText\

 ul;

 // iterate over file list
 while (($filename = readdir($dh)) !== false)

 {

 // if filename matches search pattern, print it
 if (ereg($pattern, $filename))
if(strpos($filename,'.')0)

 {
 $fh = fopen($dir . $filename, r);

 $filehead = fgets($fh);

 fclose($fh);
 echo 
 li class=\bn_bullet\
 a href=\/breaking_news/$filename\$filehead/a
 /li;
 }
 }
 echo 
 /ulp /
 /span
 /div;

 // close directory
 closedir($dh);
 }
 }

 ?

 Thank you,

 --
 Steve Marquez




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Order directory output

2008-02-08 Thread Jim Lucas

Pastor Steve wrote:

Hi, thanks for all your help today.

I have the following code and I am trying to order the output. Currently it
seems really random. Can anyone point me in the right direction?

?php

$dir = content/current/breaking_news/;

// set pattern
$pattern = .txt*|.TXT*;

// open directory and parse file list
if (is_dir($dir))
{
if ($dh = opendir($dir))
{

//This is the div that contains the wrap around for the breaking news
section.
echo 
div class=\spstory\ style=\font-family: Times New Roman, Times,
serif; font-size: 12px; width: 290px;\
div style=\width: 285px; background-color: #CC; padding:
3px;\
span class=\NormalHeadRed\Breaking News/span
br /Please check here often for breaking news stories.
/div
p /
span class=\NomalText\

ul;


// iterate over file list
while (($filename = readdir($dh)) !== false)

{

// if filename matches search pattern, print it
if (ereg($pattern, $filename))
   if(strpos($filename,'.')0)

{
$fh = fopen($dir . $filename, r);

$filehead = fgets($fh);

fclose($fh);
echo 
li class=\bn_bullet\
a href=\/breaking_news/$filename\$filehead/a
/li;
}
}
echo 
/ulp /
/span
/div;

// close directory
closedir($dh);
}
}

?

Thank you,

--
Steve Marquez




A cut down version of what you are trying to do, I think.

?php

$dir = ../../;

// set pattern
$allowed_ftypes = array('php','txt','TXT');

// open directory and parse file list
if (is_dir($dir)) {
if ( ($files = glob($dir.'*') ) !== false ) {

// This is the div that contains the wrap around for the breaking news
// section.
echo 'div
Breaking Newsbr /
Please check here often for breaking news stories.
p
span class=NomalText
ul';


// iterate over file list
foreach ( $files AS $file ) {

// if filename matches search pattern, print it
if ( in_array(array_pop(explode('.', $file) ), $allowed_ftypes ) ) {

// Open file for reading
if ( ( $fh = fopen($file, r) ) !== false ) {

// Get the first line of the file
$filehead = fgets($fh);

// Extract file name for link
$filename = array_pop(explode('/', $file));

// Display Link
echo 'lia href=/breaking_news/'.$filename.''.
  htmlspecialchars($filehead).'/a/li';

fclose($fh);
}
}
}
echo '/ul/p/span/div';
}
}

?

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Order directory output

2008-02-08 Thread Nathan Nobbe
i hooked up an spl example; and the files are sorted by name.
also, did you want that p inside or outside the span w/
class=NormalText, because the opening and closing tags are
mixed up..

?php
class FileIterator extends FilterIterator {
public function __construct(Iterator $it) {
if(!($it instanceof DirectoryIterator)) {
throw new LogicException(get_class($it) . ' must be
a DirectoryIterator!');
}
parent::__construct($it);
}

public function accept() {
if($this-getInnerIterator()-current()-isFile()) {
return true;
}
}
}

class TextInfoIterator extends ArrayIterator {
public function __construct($array, $flags=0) {
$this-ksort();
parent::__construct($array, $flags);
}

public function current() {
return 'li' . parent::current() . '/li';
}
}

$fileMatchString = '/.*(\.txt|\.TXT)$/';
$resultData = array();

foreach(new RegexIterator(new FileIterator(new
DirectoryIterator('testDir')), $fileMatchString) as $curAllowedFile) {
try {
$theFile = $curAllowedFile-openFile('r');
$theFile-setFlags(SplFileObject::DROP_NEW_LINE);
$resultData[$curAllowedFile-getFilename()] =
$theFile-fgets();
unset($theFile);// close the file ??
} catch(RuntimeException $e) {
// do something here
}
}
?
div class=spstory style=font-family: Times New Roman, Times,serif;
font-size: 12px; width: 290px;
div style=width: 285px; background-color: #CC; padding:3px;
span class=\NormalHeadRed\Breaking News/span
br /Please check here often for breaking news stories.
/div
p
span class=NomalText
ul
?php foreach(new TextInfoIterator($resultData) as
$curTextData) { ?
?=$curTextData?
?php } ?
/ul
/span
/p
/div

-nathan


Re: [PHP] Order directory output

2008-02-08 Thread Nathan Nobbe
On Fri, Feb 8, 2008 at 9:19 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:

 i hooked up an spl example; and the files are sorted by name.
 also, did you want that p inside or outside the span w/
 class=NormalText, because the opening and closing tags are
 mixed up..


damnit; i had a couple of mistakes; so sue me; its friday night!

to ensure the path is in the href; i added it
$resultData[$curAllowedFile-getPathname()] = $theFile-fgets();

to make sure the results are sorted; i sorted them after the parent
ArrayIterator was created
parent::__construct($array, $flags);
$this-ksort();

and lastly, i added the anchor tag
a href=?=$curFilename??=$curTextData?/a

i could use a drink right about now..=/

-nathan


Re: [PHP] Order directory output

2008-02-08 Thread Paul Scott

On Fri, 2008-02-08 at 21:19 -0500, Nathan Nobbe wrote:
 i hooked up an spl example; and the files are sorted by name.
 also, did you want that p inside or outside the span w/
 class=NormalText, because the opening and closing tags are
 mixed up..
 

Here is another, generic extension filter with SPL. Untested, and I have
just woken up, so if it doesn't work... :-P

class ExtensionFilter extends FilterIterator {

  private $ext; 
  private $it;

  public function __construct(DirectoryIterator $it, $ext) {
  parent::__construct($it);
  $this-it = $it;
  $this-ext = $ext;
  }
  public function accept() {
  if ( ! $this-it-isDir() ) {
$ext = array_pop(explode('.', $this-current()));
return $ext != $this-ext;
  }
  return true;
  }
}

--Paul
-- 
.
| Chisimba PHP5 Framework - http://avoir.uwc.ac.za   |
::

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] order/reorder pull out data from arrays

2006-07-12 Thread tedd
At 10:01 PM +0200 7/11/06, Jochem Maas wrote:

  Anyway I can do that?

as many as there ways to skin a cat probably :-)

Yeah, but the cat ain't going to like any of them -- Jeff Foxworthy  :-)

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order/reorder pull out data from arrays

2006-07-11 Thread Jake Gardner

Ok I understand your method now. your code does not match your output. how
would your print line produce that , $customerid ?

anyways...

$data = orders($id,$status);
$c = count($data);
$currentId;
$n = 1;
for($i=0; $i$c; $i++) {
   $orderid = $data[$i]['orderid'];
   $customerid = $data[$i]['customerid'];
   $name = $data[$i]['name'];
   if($currentid == $customerid) {
//Continue current customer group
print $orderid.' - '.$customerid.' - '.$name.'br';
   } else {
//Begin a new group...
$currentId = $customerid;
Print(Customer .$n);
$n++;
   }
}

I'm kind of headed out so its a bit rushed and the example above wont work
as given but you get the idea from the two comments I added...
On 7/11/06, Dallas Cahker [EMAIL PROTECTED] wrote:


I have an array that i would like to sort and reorder based on a simple
critera.  I already order the data but I would like to break the data now
into sections by customer id, so one customer has 5 things and another
customer has one.  How can I do that with an array.

$data = orders($id,$status);
$c = count($data);


for($i=0; $i$c; $i++) {

$orderid = $data[$i]['orderid'];
$customerid = $data[$i]['customerid'];
$name = $data[$i]['name'];
print $orderid.' - '.$customerid.' - '.$name.'br';
}

What it is currently is all the orders are ordered by the customer number,
however I would like to group it a little nicer on the output.

Current:
1234 - blah blah blah - Y - 3, 01234
1235 - blah blah blah - N - 6, 01234
1236 - blah blah blah - N - 6, 01234
1237 - blah blah blah - Y - 6, 11256
1238 - blah blah blah - N - 6, 22589
1239 - blah blah blah - N - 6, 22589
1240 - blah blah blah - Y - 6, 22589
1241 - blah blah blah - N - 6, 22589

Would like:
01234 - The Customer 1
1234 - blah blah blah - Y - 3
1235 - blah blah blah - N - 6
1236 - blah blah blah - N - 6

11256 - The Customer 2
1237 - blah blah blah - Y - 6

22589 - The Customer 3
1238 - blah blah blah - N - 6
1239 - blah blah blah - N - 6
1240 - blah blah blah - Y - 6
1241 - blah blah blah - N - 6

Anyway I can do that?




Re: [PHP] order/reorder pull out data from arrays

2006-07-11 Thread Jochem Maas
Dallas Cahker wrote:
 I have an array that i would like to sort and reorder based on a simple
 critera.  I already order the data but I would like to break the data now
 into sections by customer id, so one customer has 5 things and another
 customer has one.  How can I do that with an array.
 
 $data = orders($id,$status);
 $c = count($data);
 for($i=0; $i$c; $i++) {
 $orderid = $data[$i]['orderid'];
 $customerid = $data[$i]['customerid'];
 $name = $data[$i]['name'];
 print $orderid.' - '.$customerid.' - '.$name.'br';
 }

// something like this?:

$grouped = array();
foreach ($data as $d) {
$cid = $d['customerid'];
if (!isset($grouped[$cid])) {
$grouped[$cid] = array(
'cust' = {$cid} - {$d['name']};
'data' = array();  
);
}

// I dont know exactly what constitutes an order line
// - your example doesn't make it clear
$grouped[$cid]['data'][] = make a string of the current orderline 
here!;
}

foreach ($grouped as $cid = $data) {
echo $data['cust'],\n;
foreach ($data['data'] as $orderline) echo $orderline,\n;
}

 What it is currently is all the orders are ordered by the customer number,
 however I would like to group it a little nicer on the output.
 

...

 
 Anyway I can do that?

as many as there ways to skin a cat probably :-)

 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order of include on include()

2006-06-15 Thread Richard Lynch
On Wed, June 14, 2006 3:23 pm, blackwater dev wrote:
 If I have a file:

 /code/folder1/test.php

 and in that file, it has these includes:

 include_once(../../file1.php);
 include_once(../../file2.php);
 include_once(../../file3.php);

../ is just gonna give you headaches, sooner or later.

Just fix your include_path and be done with it.

 I then have another file:

 /code/test2.php

 That file pulls in test.php.

 include_once(folder1/test.php);

 Why do I get errors on the includes?

I don't think include_once is THAT smart...

Or maybe it just assumes you are using include_path in a sane way and
not doing this in the first place... :-)

include and include_once have nothing to do with the current file.

They ONLY look at your include_path.

Your include_path MIGHT (and probably should, in many applications)
have '.' as one of the directories in it.

But even then, I believe '.' simply means current working directory,
so unless you are dinking around with http://php.net/chdir (which you
probably shouldn't, usually) then it's just gonna be the ONE directory
of the very first PHP file loaded, no matter where all the other files
are.

Hope that helps.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] order of include on include()

2006-06-14 Thread Jay Blanchard
[snip]
Why do I get errors on the includes?  
[/snip]

Includes are included in the order of their inclusion. If an include
includes a child function (such as a class declaration) its parent must
be included first.

What error did you get? My bet is it is a path issue.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order of elements in $_POST super global

2006-06-09 Thread Richard Lynch
On Thu, June 8, 2006 9:59 am, Ben Liu wrote:
 I'm using a form (method=POST) to collect 30 boolean values from the
 end user using a series of checkboxes in the form. The form is
 arranged in a table so that the 30 check boxes are not a long list but
 rather three columns (with related items columnized). The problem is
 when I iterate through the $_POST results:

 The order in which I wish to present the checkboxes to the end user is
 different than the order I want to have in the $_POST super global and
 subsequently when I dump that information out to a text file.

You CANNOT rely on the browser to send POST data in any particular
order, by the HTTP spec.

While it's true that ALL known browsers send them in the order they
appear in the HTML, they don't have to.

And, of course, if they ever change that, a zillion scripts will break...

Still, better safe than sorry.

 What would be the best way to solve this?

Since you want them in a particular order, use the KEY of the array to
order them:

input type=checkbox name=array[0] / I'm first.
input type=checkbox name=array[1] / I'm second.
input type=checkbox name=array[2] / I'm third.


 1) Is there a way to present the checkboxes in a certain order, yet
 have the data transmitted into the $_POST super global in a different
 order?

Presentation order is all HTML.

 2) Does it make more sense to process the $_POST super global array
 and reorder the items within the array?

 3) Some other method?

 Thanks for any advice.

 - Ben

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order of elements in $_POST super global

2006-06-08 Thread Dave Goodchild

On 08/06/06, Ben Liu [EMAIL PROTECTED] wrote:


Hello All,

I'm using a form (method=POST) to collect 30 boolean values from the
end user using a series of checkboxes in the form. The form is
arranged in a table so that the 30 check boxes are not a long list but
rather three columns (with related items columnized). The problem is
when I iterate through the $_POST results:

The order in which I wish to present the checkboxes to the end user is
different than the order I want to have in the $_POST super global and
subsequently when I dump that information out to a text file.

What would be the best way to solve this?

1) Is there a way to present the checkboxes in a certain order, yet
have the data transmitted into the $_POST super global in a different
order?

2) Does it make more sense to process the $_POST super global array
and reorder the items within the array?

3) Some other method?

Thanks for any advice.

- Ben





You can access the values in the $_POST array in any order, so if you know
the checkbox names why not output them in the order you want? Or I am being
dumb here?

--

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] order of elements in $_POST super global

2006-06-08 Thread Ben Liu

Hi Dave,

No, that is definitely a possibility. Right now I am using a foreach
loop to iterate over the $_POST array and determine if each checkbox
is checked or not, if it is checked, than a related piece of data is
written into the text file. This makes for pretty compact code. I
could as you suggest, simply check each element in the array manually
using the associative keys rather than using a loop, that way I could
do it in any order I wished, but the code gets rather long with a line
for each checkbox. I anticipate this set of checkboxes/boolean
responses may increase in the future also, so having the loop allows
for some future-proofing.

- Ben

On 6/8/06, Dave Goodchild [EMAIL PROTECTED] wrote:




On 08/06/06, Ben Liu [EMAIL PROTECTED] wrote:



You can access the values in the $_POST array in any order, so if you know
the checkbox names why not output them in the order you want? Or I am being
dumb here?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order of elements in $_POST super global

2006-06-08 Thread Ron Clark

Ben Liu wrote:

Hi Dave,

No, that is definitely a possibility. Right now I am using a foreach
loop to iterate over the $_POST array and determine if each checkbox
is checked or not, if it is checked, than a related piece of data is
written into the text file. This makes for pretty compact code. I
could as you suggest, simply check each element in the array manually
using the associative keys rather than using a loop, that way I could
do it in any order I wished, but the code gets rather long with a line
for each checkbox. I anticipate this set of checkboxes/boolean
responses may increase in the future also, so having the loop allows
for some future-proofing.

- Ben

On 6/8/06, Dave Goodchild [EMAIL PROTECTED] wrote:





On 08/06/06, Ben Liu [EMAIL PROTECTED] wrote:



You can access the values in the $_POST array in any order, so if you 
know
the checkbox names why not output them in the order you want? Or I am 
being

dumb here?





why not create an array with the keys in the order you want ( $array= 
array(value1,value2,). Then loop through the array and use the 
values as keys to the $_POST variable and perform your processing that way.


foreach ($array as $value) {
   if (isset($_POST[$value]) {
do something;
   }
}


--
Ron Clark
System Administrator
Armstrong Atlantic State University


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order of elements in $_POST super global

2006-06-08 Thread Ben Liu

Der...of course. Thanks Ron! I knew the answer was simple. :-)

-Ben

On 6/8/06, Ron Clark [EMAIL PROTECTED] wrote:


why not create an array with the keys in the order you want ( $array=
array(value1,value2,). Then loop through the array and use the
values as keys to the $_POST variable and perform your processing that way.

foreach ($array as $value) {
if (isset($_POST[$value]) {
do something;
}
}


--
Ron Clark
System Administrator
Armstrong Atlantic State University


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Order of extensions in php.ini matters?

2004-10-05 Thread Ed Lazor
You have the correct order.  Exif relies on functionality provided by
mbstring.dll, therefore it must be loaded after it.

 -Original Message-
 I'm trying to use the EXIF extension (PHP 5, Windows
 XP). Order didn't seem to matter before (PHP 4). But
 now, if my php.ini is like:
 
 extension=php_exif.dll
 extension=php_mbstring.dll
 
 PHP gives an unable to load module error. But if I
 put the mbstring extension before exif in php.ini, it
 works. What's up?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Order by

2004-08-03 Thread Jake McHenry
- Original Message - 
From: Karl-Heinz Schulz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 03, 2004 10:19 PM
Subject: [PHP] Order by


 $specs_query = mysql_query(select title, information from spec where
 product=.$id order by id asc);

 But it will create the error.

 Parse error: parse error, unexpected T_STRING in
/www/docs/view_product.php
 on line 144



start the quotes again...

$specs_query = mysql_query(select title, information from spec where
product=.$id. order by id asc);


Thanks,
Jake McHenry

MIS Coordinator
Nittany Travel
http://www.nittanytravel.com
570.748.6611 x108

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Order by

2004-08-03 Thread Karl-Heinz Schulz
Thank you - stupid me

-Original Message-
From: Wesley Furgiuele [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 03, 2004 10:27 PM
To: Karl-Heinz Schulz
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Order by

Looks like you just forgot some quotes:
$specs_query = mysql_query( select title, information from spec where 
product=.$id. order by id asc );

Or just move your quotes to the end -- I think you should be fine:
$specs_query = mysql_query( select title, information from spec where 
product = $id order by id asc );

Wes

On Aug 3, 2004, at 10:19 PM, Karl-Heinz Schulz wrote:

 How can I use the Order statement for this query?

 $specs_query = mysql_query(select title, information from spec where
 product=.$id);

 I tried to use

 $specs_query = mysql_query(select title, information from spec where
 product=.$id order by id asc);

 But it will create the error.

 Parse error: parse error, unexpected T_STRING in 
 /www/docs/view_product.php
 on line 144

 What am I doing wrong?

 TIA

 Karl-Heinz

 Tracking #: 28B73BEA7EBF0B4D89E64E5EA406BF5EC2EA6912

 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Order by

2004-08-03 Thread Wesley Furgiuele
Looks like you just forgot some quotes:
$specs_query = mysql_query( select title, information from spec where 
product=.$id. order by id asc );

Or just move your quotes to the end -- I think you should be fine:
$specs_query = mysql_query( select title, information from spec where 
product = $id order by id asc );

Wes
On Aug 3, 2004, at 10:19 PM, Karl-Heinz Schulz wrote:
How can I use the Order statement for this query?
$specs_query = mysql_query(select title, information from spec where
product=.$id);
I tried to use
$specs_query = mysql_query(select title, information from spec where
product=.$id order by id asc);
But it will create the error.
Parse error: parse error, unexpected T_STRING in 
/www/docs/view_product.php
on line 144

What am I doing wrong?
TIA
Karl-Heinz
Tracking #: 28B73BEA7EBF0B4D89E64E5EA406BF5EC2EA6912
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Order by

2004-08-03 Thread Jim Grill
- Original Message - 
From: Karl-Heinz Schulz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 03, 2004 9:19 PM
Subject: [PHP] Order by


 How can I use the Order statement for this query?

 $specs_query = mysql_query(select title, information from spec where
 product=.$id);

 I tried to use

 $specs_query = mysql_query(select title, information from spec where
 product=.$id order by id asc);

 But it will create the error.

 Parse error: parse error, unexpected T_STRING in
/www/docs/view_product.php
 on line 144

 What am I doing wrong?

 TIA

 Karl-Heinz

 Tracking #: 28B73BEA7EBF0B4D89E64E5EA406BF5EC2EA6912



Hi Karl,

The problem is in your formatting.

 $specs_query = mysql_query(select title, information from spec where
 product=.$id order by id asc);


Try this instead

$specs_query = mysql_query('SELECT title, information FROM spec WHERE
product=' . $id . ' ORDER BY id ASC');

Note the use of single quotes (it's faster)

You could have just done this with double quotes:

$specs_query = mysql_query(SELECT title, information FROM spec WHERE
product=$id ORDER BY id ASC);

It might also be a good idea to put single quotes around $id if it comes
from user input:

$specs_query = mysql_query('SELECT title, information FROM spec WHERE
product=\'' . $id . '\' ORDER BY id ASC');
- OR -
$specs_query = mysql_query(SELECT title, information FROM spec WHERE
product='$id' ORDER BY id ASC);


Have fun!

Regards,

Jim Grill
Web-1 Hosting
http://www.web-1hosting.net






 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Order by

2004-08-03 Thread Karl-Heinz Schulz
Thank you for your help!

-Original Message-
From: Jim Grill [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 03, 2004 10:33 PM
To: Karl-Heinz Schulz; [EMAIL PROTECTED]
Subject: Re: [PHP] Order by

- Original Message - 
From: Karl-Heinz Schulz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 03, 2004 9:19 PM
Subject: [PHP] Order by


 How can I use the Order statement for this query?

 $specs_query = mysql_query(select title, information from spec where
 product=.$id);

 I tried to use

 $specs_query = mysql_query(select title, information from spec where
 product=.$id order by id asc);

 But it will create the error.

 Parse error: parse error, unexpected T_STRING in
/www/docs/view_product.php
 on line 144

 What am I doing wrong?

 TIA

 Karl-Heinz

 Tracking #: 28B73BEA7EBF0B4D89E64E5EA406BF5EC2EA6912



Hi Karl,

The problem is in your formatting.

 $specs_query = mysql_query(select title, information from spec where
 product=.$id order by id asc);


Try this instead

$specs_query = mysql_query('SELECT title, information FROM spec WHERE
product=' . $id . ' ORDER BY id ASC');

Note the use of single quotes (it's faster)

You could have just done this with double quotes:

$specs_query = mysql_query(SELECT title, information FROM spec WHERE
product=$id ORDER BY id ASC);

It might also be a good idea to put single quotes around $id if it comes
from user input:

$specs_query = mysql_query('SELECT title, information FROM spec WHERE
product=\'' . $id . '\' ORDER BY id ASC');
- OR -
$specs_query = mysql_query(SELECT title, information FROM spec WHERE
product='$id' ORDER BY id ASC);


Have fun!

Regards,

Jim Grill
Web-1 Hosting
http://www.web-1hosting.net






 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by

2004-01-27 Thread Stuart
christian tischler wrote:
Is there a way wuth php to create a list ordered by more than one column
like in excel or access.
something like ORDER BY points AND score
Use http://php.net/usort and use both 'columns' in the comparison function.

--
Stuart
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] order by

2004-01-27 Thread Thomas Svenson
christian tischler wrote:
 Is there a way wuth php to create a list ordered by more than one
 column like in excel or access.

 something like ORDER BY points AND score

You might want to look at GROUP BY command too
http://www.mysql.com/doc/en/Group_by_functions_and_modifiers.html

/T

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] order by

2004-01-27 Thread Marek Kilimajer
... ORDER BY points [DESC|ASC], score [DESC|ASC]

christian tischler wrote:
Is there a way wuth php to create a list ordered by more than one column
like in excel or access.
something like ORDER BY points AND score

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] order by

2004-01-27 Thread Brian V Bonini
On Tue, 2004-01-27 at 07:34, christian tischler wrote:
 Is there a way wuth php to create a list ordered by more than one column
 like in excel or access.
 
 something like ORDER BY points AND score

... ORDER BY column1, column2, etc...;

-- 
BrianGnuPG - KeyID: 0x04A4F0DC | URL: www.gfx-design.com/keys
  Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
GnuPG: http://gnupg.org
http://www.biglumber.com/x/web?qs=0x2C35011004A4F0DC
Linux Registered User #339825 at http://counter.li.org


signature.asc
Description: This is a digitally signed message part


Re: [PHP] ORDER BY RAND()....

2003-10-29 Thread Gerard Samuel
On Wednesday 29 October 2003 02:24 pm, Payne wrote:
 Hi,

 I have been working on a simple PHP script that called to a mysql
 database, where I  do the following

 SELECT url FROM sponsors ORDER BY RAND();

Try -
SELECT url FROM sponsors ORDER BY RAND() LIMIT 1;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ORDER BY RAND()....

2003-10-29 Thread Payne
Gerard Samuel wrote:

On Wednesday 29 October 2003 02:24 pm, Payne wrote:
 

Hi,

I have been working on a simple PHP script that called to a mysql
database, where I  do the following
SELECT url FROM sponsors ORDER BY RAND();
   

Try -
SELECT url FROM sponsors ORDER BY RAND() LIMIT 1;
 

I did that same thing.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] ORDER BY RAND()....

2003-10-29 Thread Chris W. Parker
Payne mailto:[EMAIL PROTECTED]
on Wednesday, October 29, 2003 11:54 AM said:

 Try -
 SELECT url FROM sponsors ORDER BY RAND() LIMIT 1;
 
 
 
 I did that same thing.

SELECT url FROM sponsors ORDER BY column RAND() LIMIT 1;

How about that one?



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ORDER BY RAND()....

2003-10-29 Thread Payne
Ok, this gives me an error. I guess what I was asking early is there 
away to print an echo without doing myrow? Why can I do echo $result 
without getting Resource id # My thinking is if you look at my first 
e-mail, my code is trying to fetch multi-rows from the database, I don't 
need multi row,  I thinking becaue fetch calls the database multi time 
that it defects the rand() function.

Payne

Chris W. Parker wrote:

Payne mailto:[EMAIL PROTECTED]
   on Wednesday, October 29, 2003 11:54 AM said:
 

Try -
SELECT url FROM sponsors ORDER BY RAND() LIMIT 1;


 

I did that same thing.
   

SELECT url FROM sponsors ORDER BY column RAND() LIMIT 1;

How about that one?



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Order of arrays

2002-11-22 Thread Marek Kilimajer
Use usort

Mako Shark wrote:


I don't think a simple sort() will do this. Is there a
way I can sort these following array values so that
all will be in numerical order, and then alphabetical
after that?

I need
Dirfiles/97
Dirfiles/98
Dirfiles/99
Dirfiles/100
Dirfiles/101
Dirfiles/102
Dirfiles/ABG1
Dirfiles/ABG2

in that order. They could originally be in any
seemingly random order, but when I'm done with it, I
need them in that order. Is there a way to do it? A
simple string sort() won't work since 9 comes after 1
and it'll order it like
'Dirfiles/100,101,102,97,98,99,ABG1,ABG2'. Any ideas?
For some reason, natsort() won't work.

__
Do you Yahoo!?
Yahoo! Mail Plus  Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] order of evaluation

2002-04-09 Thread Analysis Solutions

Yo Erik:

On Tue, Apr 09, 2002 at 11:39:31AM -0400, Erik Price wrote:
 
 elseif (!empty($_POST['newpassword'])  
 !$user-set_password($_POST['newpassword']))

Your order of evaluation is correct.  But, considering the password
length is evaluated in the set_password() function, checking empty() 
first is a waste of time in 99% of cases.

Later,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] order of evaluation

2002-04-09 Thread Erik Price


On Tuesday, April 9, 2002, at 12:24  PM, Analysis  Solutions wrote:

 Yo Erik:

 On Tue, Apr 09, 2002 at 11:39:31AM -0400, Erik Price wrote:

 elseif (!empty($_POST['newpassword']) 
 !$user-set_password($_POST['newpassword']))

 Your order of evaluation is correct.  But, considering the password
 length is evaluated in the set_password() function, checking empty()
 first is a waste of time in 99% of cases.

Hm.  I threw in a test echo statement in the class method, to make sure 
that it wasn't being accessed if $_POST['newpassword'] is in fact 
empty.  The test echo statement is displaying on the receiving page, 
however, even though there is nothing in $_POST['newpassword'].

Here's my class method:


function set_password($password)
{   echo p class=\warning\set_password() accessed, the new 
password is '$this-password'/p; // 
remove 
after bug testing
  if (!preg_match('/\d/', $password) ||
  !preg_match('/^[-A-Za-z0-9!@#$%^*()_ +=\?]{6,10}$/', 
$password) ||
  !preg_match('/[A-Za-z]/', $password)) {
return false;
  } else {
  $this-password = $password;
  return true;
  }
}


and here's the code that's hitting the method (but shouldn't be):


// the Person class is needed here
require_once('./includes/Person_class.inc');

// create a new Person instance
$user = new Person();

if (!$user-set_email($_POST['email'])) {
$error_message = invalid email;
} elseif (  (!empty($_POST['newpassword'])  $_POST['newpassword']
!= 
$_POST['confirmpassword']) ||
(!$user-set_password($_POST['newpassword']))   ) {
$error_message = p class=\warning\/p\n;
} else {
$success_message = changeinfo_process(serialize($user));
}

if ($error_message) {
return $error_message;
} elseif ($success_message) {
return $success_message;
} else {
die(No error or success message?);
}

// destroy the Person instance
unset($user);



On the next page, the echo from my class method is appearing:


set_password() accessed, the new password is ''


But as you can see, the value of $_POST['newpassword'] is an empty 
string -- shouldn't the elseif statement testing for 
!empty($_POST['newpassword'] catch this?

Much thanks to anyone with clearer thinking than I.


Erik





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] order of evaluation

2002-04-09 Thread Erik Price

Hey I'm sorry Dan and everyone, I realize my mistake -- if you're 
curious it's in my if/elseif/else chain, I explain the problem below 
(scroll down):


Erik

On Tuesday, April 9, 2002, at 03:00  PM, Erik Price wrote:


 Hm.  I threw in a test echo statement in the class method, to make sure 
 that it wasn't being accessed if $_POST['newpassword'] is in fact 
 empty.  The test echo statement is displaying on the receiving page, 
 however, even though there is nothing in $_POST['newpassword'].

 Here's my class method:

 
 function set_password($password)
 { echo p class=\warning\set_password() accessed, the new 
 password is   '$this-password'/p; // 
remove 
 after bug testing
  if (!preg_match('/\d/', $password) ||
  !preg_match('/^[-A-Za-z0-9!@#$%^*()_ +=\?]{6,10}$/', 
 $password) ||
  !preg_match('/[A-Za-z]/', $password)) {
   return false;
  } else {
  $this-password = $password;
  return true;
  }
 }
 

 and here's the code that's hitting the method (but shouldn't be):

 
   // the Person class is needed here
   require_once('./includes/Person_class.inc');

   // create a new Person instance
   $user = new Person();
   
   if (!$user-set_email($_POST['email'])) {
   $error_message = invalid email;
   } elseif (  (!empty($_POST['newpassword'])  $_POST['newpassword']
!= 
 $_POST['confirmpassword']) ||
   (!$user-set_password($_POST['newpassword']))   ) {

What happened was the elseif test I was performing was checking to see 
if either one of two conditions was true:

1st condition: newpassword is empty, and newpassword does not equal 
confirmpassword
2nd condition: set_password() fails

In my case, both newpassword and confirmpassword were empty strings, so 
the first condition evaluated to true.  This forced the parser to 
evaluate the second part of the expression (after the ||), which 
accessed the set_password() method after all.

By adding a second !empty($_POST['newpassword']) to the second half of 
the expression (after the ||), I solved my problem.



   $error_message = p class=\warning\/p\n;
   } else {
   $success_message = changeinfo_process(serialize($user));
   }
   
   if ($error_message) {
   return $error_message;
   } elseif ($success_message) {
   return $success_message;
   } else {
   die(No error or success message?);
   }
   
   // destroy the Person instance
   unset($user);

 

 On the next page, the echo from my class method is appearing:

 
 set_password() accessed, the new password is ''
 

 But as you can see, the value of $_POST['newpassword'] is an empty 
 string -- shouldn't the elseif statement testing for 
 !empty($_POST['newpassword'] catch this?

 Much thanks to anyone with clearer thinking than I.


 Erik



 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]


 -- PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php









Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Order of focus for text entry inputs

2001-09-14 Thread mgeier

This has nothing to do with PHP.

Find a good HTML reference page on the net and look up input and
TABINDEX
http://www.idocs.com/tags/forms/_INPUT_TABINDEX.html

[EMAIL PROTECTED] wrote:
 I have a web page that is generated by a php script and on this page
 there are several html text entry slots such as
 echo bSpecial Notes:/binput name=\specialNotes\
 size=\65\$prodNotes;
 on one page.  I fill in several of these input slots with default
 values, but there are about 3-4 that require the user to manually type
 an answer.  I was wondering if there was a way to control which text
 entry slots the cursor will go to when the user hits tab?  Ideally I
 would like the cursor to automatically move first to the three that
 require the user to type something, and then move on to the slots that
 already have a default value.  Is this possible in php, I didn't see any

 reference to giving items focus in the manual?  If it is not possible in

 php, is there some way that I can have this web page (that is being
 generated by a php script) use javascript to create my desired order of
 focus?  In general I have not seen any javascript inside a php script,
 although judging from a few other messages, this does seem to be
 possible.
 
 Thanks for any ideas,
 Andrew V. Romero
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

 
  

--
Michael Geier
CDM Sports, Inc. - Systems Administrator
 email: [EMAIL PROTECTED]
 phone: 314.991.1511 x 6505
 pager: 314.318.9414 || [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Order of focus for text entry inputs

2001-09-13 Thread David Robley

On Fri, 14 Sep 2001 14:53, Andrew V. Romero wrote:
 I have a web page that is generated by a php script and on this page
 there are several html text entry slots such as
 echo bSpecial Notes:/binput name=\specialNotes\
 size=\65\$prodNotes;
 on one page.  I fill in several of these input slots with default
 values, but there are about 3-4 that require the user to manually type
 an answer.  I was wondering if there was a way to control which text
 entry slots the cursor will go to when the user hits tab?  Ideally I
 would like the cursor to automatically move first to the three that
 require the user to type something, and then move on to the slots that
 already have a default value.  Is this possible in php, I didn't see
 any reference to giving items focus in the manual?  If it is not
 possible in php, is there some way that I can have this web page (that
 is being generated by a php script) use javascript to create my desired
 order of focus?  In general I have not seen any javascript inside a php
 script, although judging from a few other messages, this does seem to
 be possible.

 Thanks for any ideas,
 Andrew V. Romero

That's a HTML thing. From Wilbur (about the INPUT tag)

The ACCESSKEY and TABINDEX attributes apply to all input types except 
hidden. ACCESSKEY specifies a single Unicode character as a shortcut key 
for giving focus to the form control. Authors can set the access key on 
the INPUT element or the LABEL element associated with it. Entities (e.g. 
eacute;) may be used as the ACCESSKEY value.

The TABINDEX attribute specifies a number between 0 and 32767 to indicate 
the tabbing order of the element. A form control with TABINDEX=0 or no 
TABINDEX attribute will be visited after any elements with a positive 
TABINDEX. Among positive TABINDEX values, the lower number receives focus 
first. In the case of a tie, the element appearing first in the HTML 
document takes precedence.


-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   The world is so big and so global now.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Order of focus for text entry inputs

2001-09-13 Thread Don Read


On 14-Sep-2001 Andrew V. Romero wrote:
 I have a web page that is generated by a php script and on this page
 there are several html text entry slots such as
 echo bSpecial Notes:/binput name=\specialNotes\
 size=\65\$prodNotes;
 on one page.  I fill in several of these input slots with default
 values, but there are about 3-4 that require the user to manually type
 an answer.  I was wondering if there was a way to control which text
 entry slots the cursor will go to when the user hits tab?  Ideally I
 would like the cursor to automatically move first to the three that
 require the user to type something, and then move on to the slots that
 already have a default value.  Is this possible in php, I didn't see any
 reference to giving items focus in the manual?  If it is not possible in
 php, is there some way that I can have this web page (that is being
 generated by a php script) use javascript to create my desired order of
 focus?  In general I have not seen any javascript inside a php script,
 although judging from a few other messages, this does seem to be
 possible.
 
 Thanks for any ideas,
 Andrew V. Romero

 http://www.w3.org/TR/html401/interact/forms.html#h-17.11

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] order of update??

2001-08-23 Thread Sam Masiello


The order doesn't matter, but perhaps you might want to put single quotes
around your $a at the end of your SQL statement.  You didn't mention the
error that you were getting, but this might help nonetheless :)

update tablename set x='$x', y='$y', z='$z' where a='$a';

HTH

Sam Masiello
Software Quality Assurance Engineer
Synacor
(716) 853-1362 x289
[EMAIL PROTECTED]

 -Original Message-
From:   Gerard Samuel [mailto:[EMAIL PROTECTED]]
Sent:   Thursday, August 23, 2001 3:00 PM
To: PHP
Subject:[PHP] order of update??

My seem stupid to some, but when running
update tablename set x='$x', y='$y', z='$z' where a=$a;
Does it matter if it the set were in backwards order ie z, y, x ??

Just curious, Im having a problem and I dont know if its because of the
order

Thanks


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ORDER PROBLEMS

2001-05-15 Thread Miles Thompson

Rafael,

Couple of things ... see below. I'm doing this without checking the MySQL 
docs, so validate this against them.

At 08:22 PM 5/15/01 -0300, Rafael Faria wrote:
Hello Guys,

i'm with problems

first i try to add a value like 8.55 into my sql data base that was set 
up to DOUBLE (10,0) and isn't work... i don't know how this work... but 
i'm here to ask for someone explain me.

Try DOUBLE(10,2), that will provide for the decimal places.


well... i did with varchar to add this value as i want to..

do i have a lot of values like


votes  average
   2 8.5
   10   5.5
   1 10
   205.1


and i wanna sort by votes and average

have someway to do that?

Generally, when you store numeric values in a character field, you have to 
left pad them with zeroes otherwise you get strange ordering behaviour. If 
you want to do arithmetic on these values, don't store them as characters, 
store them as one of the numeric types.

If you store numbers as characters, don't waste space with varchar, use a 
straight char type.

As for ordering, that is a function of your SELECT statement. Example:

 select * from vote_results order by votes  will order results by an 
ascending count of votes.

 select * from vote_results order by votes desc  will order results by a 
descending count of votes.

 select * from vote_results order by votes, average  will order results 
by an ascending count of votes and then by ascending averages within the 
returned set. (I don't know what the point of this would be.)

A comment on your average field. Databases can calculate averages _very_ 
quickly and it may be better to do that in your SELECT statement. Heres an 
extract from the manual:
AVG(expr)
 Returns the average value of expr:

 mysql select student_name, AVG(test_score)
from student
GROUP BY student_name;

Hope you find this helpful - Miles Thompson

PS br - Brazil? I'm not up on my country codes.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Order by Date (Newbie)

2001-02-23 Thread Joe Stump

To order by dates use SQL

select * from news order by PostDate DESC;

and then make sure that PostDate is a date or datetime - hell even an int with
a unix timestamp (aka time()) will work.

--Joe

On Fri, Feb 23, 2001 at 07:52:54PM -0500, Brian S. Drexler wrote:
 Ok, I must be missing something, but does anyone have a script that will
 order by the closest date in the future that hasn't been here yet.  Did that
 make sense?
 
 Brian
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 

---
Joe Stump, PHP Hacker, [EMAIL PROTECTED] -o)
http://www.miester.org http://www.care2.com /\\
"It's not enough to succeed. Everyone else must fail" -- Larry Ellison _\_V
---


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Order by Date (Newbie)

2001-02-23 Thread Kyndig

On Fri, 23 Feb 2001, Brian S. Drexler wrote:
 Ok, I must be missing something, but does anyone have a script that will
 order by the closest date in the future that hasn't been here yet.  Did that
 make sense?
 
 Brian
 
$plusten = mktime(0,0,0,date("m"),date("d")+10,date("Y") );

Will take todays day, and add 10 days to it.
-- 
Kind Regards,
---
Kyndig
Online Text Game Resource Site:  http://www.kyndig.com
ICQ#10451240


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]