Re: [PHP-DB] Database Sorting by date

2002-04-05 Thread Ron Allen

I figured out the problemit was in my query statement

SELECT * FROM $table where DATE LIKE '$month%' ORDER BY DATE desc

This works perfectly, but in the effort to achieve greatness (won't ever
happen), is this the most efficient way?

Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ron,

 This would indicate that $table was not set.  Or that the table indicated
in
 $table does not exist.  Print out $query; is it as you expected?
 Enter the SELECT at the mysql command prompt: what is the result?

 -Original Message-
 From: Allen, Ronald L CIV [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 04, 2002 8:41 AM
 To: Rick Emery
 Subject: RE: [PHP-DB] Database Sorting by date


 The query fails when I try to look at a month it says Query Failed

 Ronald L. Allen (MCSE NT, MCP, CCNA)
 SR. LAN/WAN Administrator
 SFOR - Hungary, Croatia
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 +36-82-50 ext. 22580
   DSN: 760-2000


 -Original Message-
 From: Rick Emery [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 04, 2002 16:43
 To: 'Ron Allen'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Database Sorting by date


 Ron,

 What problem are you having?  I'm looking at your code, and it's so clean,
I
 could eat off of it. My only suggestion would be that $month will NEVER ==
 NULL.  If you are testing for NULL, the test is: if ($month == NULL )

 Second, $month will be assigned a value, so it will never be NULL either.

 BTW, what is in drop.inc?

 -Original Message-
 From: Ron Allen [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 04, 2002 8:09 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Database Sorting by date


 Here is the problem I want to be able to view all or search through the
 currency lists in the database by the month. Any help would be great!!!

 Here is the code

 TABLE
 FORM name=currency METHOD=POST ACTION=testtest.php
 TR HEIGHT=20TD COLSPAN=2FONT SIZE=+0 FACE=VERDANA BR TRTD
 ALIGN=LEFT BSelect a CCSD:/BBRselect name=month
 onChange=document.currency.submit()
 option value=NULLSELECT
 option value=NULLVIEW ALL
 option value=2002-03March 2002
 option value=2002-04April 2002
 option value=2002-05May 2002
 option value=2002-06June 2002
 option value=2002-07July 2002
 option value=2002-08August 2002
 option value=2002-09September 2002
 option value=2002-10October 2002
 option value=2002-11November 2002
 option value=2002-12December 2002
 /TD/tr
 /table
 ?


 include '..\drop.php';
 $DBName = currency;
 $table = currency;


 $db = mysql_connect($DBhost,$DBuser,$DBpass) or die(Problem
 connecting);
 mysql_select_db($DBName) or die(Problem selecting database); if
($month
 == NULL){  $query = SELECT * FROM $table;  $result =
mysql_query($query)
 or die (Query failed); //let's get the number of rows in our result so
we
 can use it in a for loop $numofrows = mysql_num_rows($result); } else {
 $query = SELECT * FROM $table where DATE = preg_match(Y-m,'$month'))
ORDER
 BY DATE; $result = mysql_query($query) or die (Query failed); //let's
get
 the number of rows in our result so we can use it in a for loop $numofrows
=
 mysql_num_rows($result); }

 ?

 ?
 echo TABLE BORDER=\1\\n;
 echo TR

bgcolor=\#709fff\TDcenterbDATE/b/center/TDTDcenterbEURO
 /b/center/TDTDcenterbEURO

RECONVERSION/b/center/TDTDcenterbKM/b/center/TDTDcenter
 bKM

RECONVERSION/b/center/TDTDcenterbHUF/b/center/TDTDcente
 rbKUNA/b/center/TD/TR\n;
 for($i = 0; $i  $numofrows; $i++) {
 $row = mysql_fetch_array($result); //get a row from our result set
 if($i % 2) { //this means if there is a remainder
 echo TR bgcolor=\#d3d3d3\\n;
 } else { //if there isn't a remainder we will do the else
 echo TR bgcolor=\#f0f0f0\\n;
 }
 echo

TD.$row['DATE']./TDTD.$row['EURO']./TDTD.$row['EURORECON'].

/TDTD.$row['KM']./TDTD.$row['KMRECON']./TDTD.$row['HUF'].
 /TDTD.$row['KUNA']./TD\n;
 echo /TR\n;
 }
 //now let's close the table and be done with it
 echo /TABLE\n;
 ?




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



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




[PHP-DB] Database Sorting by date

2002-04-04 Thread Ron Allen

Here is the problem I want to be able to view all or search through the
currency lists in the database by the month.
Any help would be great!!!

Here is the code

TABLE
FORM name=currency METHOD=POST ACTION=testtest.php
TR HEIGHT=20TD COLSPAN=2FONT SIZE=+0 FACE=VERDANA
BR
TRTD ALIGN=LEFT
BSelect a CCSD:/BBRselect name=month
onChange=document.currency.submit()
option value=NULLSELECT
option value=NULLVIEW ALL
option value=2002-03March 2002
option value=2002-04April 2002
option value=2002-05May 2002
option value=2002-06June 2002
option value=2002-07July 2002
option value=2002-08August 2002
option value=2002-09September 2002
option value=2002-10October 2002
option value=2002-11November 2002
option value=2002-12December 2002
/TD/tr
/table
?


include '..\drop.php';
$DBName = currency;
$table = currency;


$db = mysql_connect($DBhost,$DBuser,$DBpass) or die(Problem
connecting);
mysql_select_db($DBName) or die(Problem selecting database);
if ($month == NULL){
 $query = SELECT * FROM $table;
 $result = mysql_query($query) or die (Query failed);
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
} else {
$query = SELECT * FROM $table where DATE = preg_match(Y-m,'$month')) ORDER
BY DATE;
$result = mysql_query($query) or die (Query failed);
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
}

?

?
echo TABLE BORDER=\1\\n;
echo TR
bgcolor=\#709fff\TDcenterbDATE/b/center/TDTDcenterbEURO
/b/center/TDTDcenterbEURO
RECONVERSION/b/center/TDTDcenterbKM/b/center/TDTDcenter
bKM
RECONVERSION/b/center/TDTDcenterbHUF/b/center/TDTDcente
rbKUNA/b/center/TD/TR\n;
for($i = 0; $i  $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo TR bgcolor=\#d3d3d3\\n;
} else { //if there isn't a remainder we will do the else
echo TR bgcolor=\#f0f0f0\\n;
}
echo
TD.$row['DATE']./TDTD.$row['EURO']./TDTD.$row['EURORECON'].
/TDTD.$row['KM']./TDTD.$row['KMRECON']./TDTD.$row['HUF'].
/TDTD.$row['KUNA']./TD\n;
echo /TR\n;
}
//now let's close the table and be done with it
echo /TABLE\n;
?




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




RE: [PHP-DB] Database Sorting by date

2002-04-04 Thread Rick Emery

Ron,

What problem are you having?  I'm looking at your code, and it's so clean, I
could eat off of it.
My only suggestion would be that $month will NEVER == NULL.  If you are
testing for NULL, the test is:
if ($month == NULL )

Second, $month will be assigned a value, so it will never be NULL either.

BTW, what is in drop.inc?

-Original Message-
From: Ron Allen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 8:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Database Sorting by date


Here is the problem I want to be able to view all or search through the
currency lists in the database by the month.
Any help would be great!!!

Here is the code

TABLE
FORM name=currency METHOD=POST ACTION=testtest.php
TR HEIGHT=20TD COLSPAN=2FONT SIZE=+0 FACE=VERDANA
BR
TRTD ALIGN=LEFT
BSelect a CCSD:/BBRselect name=month
onChange=document.currency.submit()
option value=NULLSELECT
option value=NULLVIEW ALL
option value=2002-03March 2002
option value=2002-04April 2002
option value=2002-05May 2002
option value=2002-06June 2002
option value=2002-07July 2002
option value=2002-08August 2002
option value=2002-09September 2002
option value=2002-10October 2002
option value=2002-11November 2002
option value=2002-12December 2002
/TD/tr
/table
?


include '..\drop.php';
$DBName = currency;
$table = currency;


$db = mysql_connect($DBhost,$DBuser,$DBpass) or die(Problem
connecting);
mysql_select_db($DBName) or die(Problem selecting database);
if ($month == NULL){
 $query = SELECT * FROM $table;
 $result = mysql_query($query) or die (Query failed);
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
} else {
$query = SELECT * FROM $table where DATE = preg_match(Y-m,'$month')) ORDER
BY DATE;
$result = mysql_query($query) or die (Query failed);
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
}

?

?
echo TABLE BORDER=\1\\n;
echo TR
bgcolor=\#709fff\TDcenterbDATE/b/center/TDTDcenterbEURO
/b/center/TDTDcenterbEURO
RECONVERSION/b/center/TDTDcenterbKM/b/center/TDTDcenter
bKM
RECONVERSION/b/center/TDTDcenterbHUF/b/center/TDTDcente
rbKUNA/b/center/TD/TR\n;
for($i = 0; $i  $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo TR bgcolor=\#d3d3d3\\n;
} else { //if there isn't a remainder we will do the else
echo TR bgcolor=\#f0f0f0\\n;
}
echo
TD.$row['DATE']./TDTD.$row['EURO']./TDTD.$row['EURORECON'].
/TDTD.$row['KM']./TDTD.$row['KMRECON']./TDTD.$row['HUF'].
/TDTD.$row['KUNA']./TD\n;
echo /TR\n;
}
//now let's close the table and be done with it
echo /TABLE\n;
?




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

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




RE: [PHP-DB] Database Sorting by date

2002-04-04 Thread Rick Emery

Ron,

This would indicate that $table was not set.  Or that the table indicated in
$table does not exist.  Print out $query; is it as you expected?
Enter the SELECT at the mysql command prompt: what is the result?

-Original Message-
From: Allen, Ronald L CIV [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 8:41 AM
To: Rick Emery
Subject: RE: [PHP-DB] Database Sorting by date


The query fails when I try to look at a month it says Query Failed

Ronald L. Allen (MCSE NT, MCP, CCNA)
SR. LAN/WAN Administrator 
SFOR - Hungary, Croatia
[EMAIL PROTECTED]
[EMAIL PROTECTED]
+36-82-50 ext. 22580
  DSN: 760-2000


-Original Message-
From: Rick Emery [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, April 04, 2002 16:43
To: 'Ron Allen'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Database Sorting by date


Ron,

What problem are you having?  I'm looking at your code, and it's so clean, I
could eat off of it. My only suggestion would be that $month will NEVER ==
NULL.  If you are testing for NULL, the test is: if ($month == NULL )

Second, $month will be assigned a value, so it will never be NULL either.

BTW, what is in drop.inc?

-Original Message-
From: Ron Allen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 8:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Database Sorting by date


Here is the problem I want to be able to view all or search through the
currency lists in the database by the month. Any help would be great!!!

Here is the code

TABLE
FORM name=currency METHOD=POST ACTION=testtest.php
TR HEIGHT=20TD COLSPAN=2FONT SIZE=+0 FACE=VERDANA BR TRTD
ALIGN=LEFT BSelect a CCSD:/BBRselect name=month
onChange=document.currency.submit()
option value=NULLSELECT
option value=NULLVIEW ALL
option value=2002-03March 2002
option value=2002-04April 2002
option value=2002-05May 2002
option value=2002-06June 2002
option value=2002-07July 2002
option value=2002-08August 2002
option value=2002-09September 2002
option value=2002-10October 2002
option value=2002-11November 2002
option value=2002-12December 2002
/TD/tr
/table
?


include '..\drop.php';
$DBName = currency;
$table = currency;


$db = mysql_connect($DBhost,$DBuser,$DBpass) or die(Problem
connecting);
mysql_select_db($DBName) or die(Problem selecting database); if ($month
== NULL){  $query = SELECT * FROM $table;  $result = mysql_query($query)
or die (Query failed); //let's get the number of rows in our result so we
can use it in a for loop $numofrows = mysql_num_rows($result); } else {
$query = SELECT * FROM $table where DATE = preg_match(Y-m,'$month')) ORDER
BY DATE; $result = mysql_query($query) or die (Query failed); //let's get
the number of rows in our result so we can use it in a for loop $numofrows =
mysql_num_rows($result); }

?

?
echo TABLE BORDER=\1\\n;
echo TR
bgcolor=\#709fff\TDcenterbDATE/b/center/TDTDcenterbEURO
/b/center/TDTDcenterbEURO
RECONVERSION/b/center/TDTDcenterbKM/b/center/TDTDcenter
bKM
RECONVERSION/b/center/TDTDcenterbHUF/b/center/TDTDcente
rbKUNA/b/center/TD/TR\n;
for($i = 0; $i  $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo TR bgcolor=\#d3d3d3\\n;
} else { //if there isn't a remainder we will do the else
echo TR bgcolor=\#f0f0f0\\n;
}
echo
TD.$row['DATE']./TDTD.$row['EURO']./TDTD.$row['EURORECON'].
/TDTD.$row['KM']./TDTD.$row['KMRECON']./TDTD.$row['HUF'].
/TDTD.$row['KUNA']./TD\n;
echo /TR\n;
}
//now let's close the table and be done with it
echo /TABLE\n;
?




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

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