[PHP-DB] RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...

2001-10-25 Thread Tim Foster

> From: Chris Newbill [mailto:[EMAIL PROTECTED]]

> >snip... (been doing VBScript on ASP for several years, tho).
>
> I feel sorry for you. :)

;) Never fear. It works, does what it needs to do (so long as it's properly patched ;) 
and
I make a fist-full of money for moon-lighting. Can't complain too loudly, eh?


> >If you're going to store it as an integer, why not store "10/24/2001"
> >as MMDD
> A better way to do integer date is a UNIX timestamp.  This will sort just as
> easy as the method above.
>
> By looking at the date() function you should be able to see immediately the
> benefit in ease-of-use (not to mention portability in the DB) and formating
> options available for the timestamp.
>
> http://www.php.net/date
>
> -Chris

Don't get me wrong.. I'm quite comfortable with manipulating dates (well.. as far as M$
goes), and I fully intend to continue using DATE fields and functions to handle my date
needs. I'm too lazy to re-invent the wheel.

The crux of my question was aimed only at those who didn't want to use DATE fields and
would rather use int fields instead. I wanted to make sure I wasn't missing some cool
feature of PHP.  ..and the feedback I'm getting indicates that my general 
understanding of
dates in ASP is not too different with PHP.

TIM
-Things are more like they are today than they ever have been before.


-- 
PHP Database 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-DB] RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...

2001-10-25 Thread Chris Newbill

-Original Message-
From: Tim Foster [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 25, 2001 8:19 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...


>snip... (been doing VBScript on ASP for several years,
>tho).

I feel sorry for you. :)

>I'm curious...
>
>If you're going to store it as an integer, why not store "10/24/2001" as
MMDD
>(20011024). This gives you the added benefit of being able to have the db
sort your
>fields. This even works if you want to include the time with your date
(provided all dates
>in the field consistently contain the same *amount* of info). For example,
noon on
>Christmas will always be lower than noon of the following New Year ..as it
should be:
>
>/MM/DD 20011225< 20020101
>/MM/DD HH:MM   200112251200< 200201011200
>/MM/DD HH:MM:SS2001122512  < 2002010112

A better way to do integer date is a UNIX timestamp.  This will sort just as
easy as the method above.

By looking at the date() function you should be able to see immediately the
benefit in ease-of-use (not to mention portability in the DB) and formating
options available for the timestamp.

http://www.php.net/date

-Chris


>> -Original Message-
>> From: Mike Frazer [mailto:[EMAIL PROTECTED]]
>> Sent: Wednesday, October 24, 2001 7:54 AM
>> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
>> Subject: Re: [PHP-DB] PHP and MySQL queries...
>>
>>
>> Agreed.  This is especially useful when you need to conserve every byte
you
>> can; a timestamp of "10/24/2001" or something similar is going to take 10
>> bytes as a string and an indeterminate number of bytes for an actual
>> timestamp because of system variations, whereas an integer value of
10242001
>> will take you 2-4 bytes depending on the type of int you declare.  Not a
lot
>> of space, but assume for a second you have 30 fields in your database and
5
>> million rows...suddenly those 6-8 bytes have multiplied on this one field
>> alone.  Space and speed are important in DBs :)
>>
>> Mike Frazer


-- 
PHP Database 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-DB] RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...

2001-10-25 Thread Tim Foster

RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...Agreed.
Personally, I refuse to keep date values in fields that are not DATE fields
of some kind. Too much trouble.

TIM
-How do "Do Not Walk On Grass" signs get there?

  -Original Message-
  From: Robinson, Mike [mailto:[EMAIL PROTECTED]]

  Mysql permits all manner of formats for date/time storage,
  and a whole slew of functions for retrieving date/time
  info in useful, meaningful ways.

  For me, parsing date/time stuff before an insert or after a
  select is just plain bad practice, IMHO, when the data can go
  in and out in the format required without parsing, particularly
  with resource-costly tools like regex and the like.






[PHP-DB] RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...

2001-10-25 Thread Robinson, Mike
Title: RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...





http://mysql.com/documentation/mysql/bychapter/manual_Reference.html#Date_and_time_types


Mysql permits all manner of formats for date/time storage,
and a whole slew of functions for retrieving date/time
info in useful, meaningful ways.


For me, parsing date/time stuff before an insert or after a
select is just plain bad practice, IMHO, when the data can go
in and out in the format required without parsing, particularly
with resource-costly tools like regex and the like.


Date/time select controls (I think there's some on devshed
and/or Zend) and mysql's built-in date/time functions rock.



 Mike Robinson
 IT / Developer - Toronto Star TV
 Phone: 416.945.8786
 Fax: 416.869.4566
 Email: [EMAIL PROTECTED]



Tim Foster wrote:


> If there's something about PHP/MySQL that makes this point 
> moot, please let me know.




http://www.torontostartv.com - Webcasting & Production
http://www.tmgtv.ca - Hometown Television
http://www.thestar.com - Canada’s largest daily newspaper, The Toronto Star, online



-- 
PHP Database 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-DB] PHP and MySQL queries...

2001-10-25 Thread Steve Cayford

Oop. I guess I missed the point of that question. Still, the MySQL 
manual says a DATE takes 3 bytes, DATETIME 8 bytes, and TIMESTAMP 4 
bytes. That seems fairly efficient. Using an INT for a date might 
actually take up more space.

-Steve

On Thursday, October 25, 2001, at 09:34  AM, Steve Cayford wrote:

> Yep, MySQL has DATE, DATETIME, and TIMESTAMP field types. You can order 
> by them and everything.
>
> -Steve
>
> On Thursday, October 25, 2001, at 09:18  AM, Tim Foster wrote:
>
>> I'm new to this list, to PHP and to MySQL (been doing VBScript on ASP 
>> for several years,
>> tho).
>>
>> I'm curious...
>>
>> If you're going to store it as an integer, why not store "10/24/2001" 
>> as MMDD
>> (20011024). This gives you the added benefit of being able to have the 
>> db sort your
>> fields. This even works if you want to include the time with your date 
>> (provided all dates
>> in the field consistently contain the same *amount* of info). For 
>> example, noon on
>> Christmas will always be lower than noon of the following New Year 
>> ..as it should be:
>>
>> /MM/DD   20011225< 20020101
>> /MM/DD HH:MM 200112251200< 200201011200
>> /MM/DD HH:MM:SS  2001122512  < 2002010112
>>
>> I'm betting there's no easy way to sort it if you store it as MM/DD/YY
>>
>> MM/DD/   10242001 < 12252001 (good)
>> ..but NOT less than the following New Year's
>> MM/DD/   10242001 > 01012002 (bad)
>>
>> Granted, you might take up a bit more space in the DB, which would 
>> have a tiny impact on
>> performance(??), but an extra $100 on the hard drive would effectively 
>> eliminate any
>> reasonable space considerations and (IMHO) reduce the amount of 
>> programming/debugging to
>> more than justify the overhead.
>>
>> FWIW, M$ likes to store their dates as two integers: one to hold the 
>> date portion, the
>> other to hold the hours:minutes:seconds portion.
>>
>> If there's something about PHP/MySQL that makes this point moot, 
>> please let me know.
>>
>> TIM
>> -He who always plows a straight furrow is in a rut.
>>
>>
>>> -Original Message-
>>> From: Mike Frazer [mailto:[EMAIL PROTECTED]]
>>> Sent: Wednesday, October 24, 2001 7:54 AM
>>> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
>>> Subject: Re: [PHP-DB] PHP and MySQL queries...
>>>
>>>
>>> Agreed.  This is especially useful when you need to conserve every 
>>> byte you
>>> can; a timestamp of "10/24/2001" or something similar is going to 
>>> take 10
>>> bytes as a string and an indeterminate number of bytes for an actual
>>> timestamp because of system variations, whereas an integer value of 
>>> 10242001
>>> will take you 2-4 bytes depending on the type of int you declare.  
>>> Not a lot
>>> of space, but assume for a second you have 30 fields in your database 
>>> and 5
>>> million rows...suddenly those 6-8 bytes have multiplied on this one 
>>> field
>>> alone.  Space and speed are important in DBs :)
>>>
>>> Mike Frazer
>>
>>
>> --
>> PHP Database 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: php-list-
>> [EMAIL PROTECTED]
>>
>
>
> -- PHP Database 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 Database 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-DB] PHP and MySQL queries...

2001-10-25 Thread Steve Cayford

Yep, MySQL has DATE, DATETIME, and TIMESTAMP field types. You can order 
by them and everything.

-Steve

On Thursday, October 25, 2001, at 09:18  AM, Tim Foster wrote:

> I'm new to this list, to PHP and to MySQL (been doing VBScript on ASP 
> for several years,
> tho).
>
> I'm curious...
>
> If you're going to store it as an integer, why not store "10/24/2001" 
> as MMDD
> (20011024). This gives you the added benefit of being able to have the 
> db sort your
> fields. This even works if you want to include the time with your date 
> (provided all dates
> in the field consistently contain the same *amount* of info). For 
> example, noon on
> Christmas will always be lower than noon of the following New Year ..as 
> it should be:
>
> /MM/DD20011225< 20020101
> /MM/DD HH:MM  200112251200< 200201011200
> /MM/DD HH:MM:SS   2001122512  < 2002010112
>
> I'm betting there's no easy way to sort it if you store it as MM/DD/YY
>
> MM/DD/10242001 < 12252001 (good)
> ..but NOT less than the following New Year's
> MM/DD/10242001 > 01012002 (bad)
>
> Granted, you might take up a bit more space in the DB, which would have 
> a tiny impact on
> performance(??), but an extra $100 on the hard drive would effectively 
> eliminate any
> reasonable space considerations and (IMHO) reduce the amount of 
> programming/debugging to
> more than justify the overhead.
>
> FWIW, M$ likes to store their dates as two integers: one to hold the 
> date portion, the
> other to hold the hours:minutes:seconds portion.
>
> If there's something about PHP/MySQL that makes this point moot, please 
> let me know.
>
> TIM
> -He who always plows a straight furrow is in a rut.
>
>
>> -Original Message-
>> From: Mike Frazer [mailto:[EMAIL PROTECTED]]
>> Sent: Wednesday, October 24, 2001 7:54 AM
>> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
>> Subject: Re: [PHP-DB] PHP and MySQL queries...
>>
>>
>> Agreed.  This is especially useful when you need to conserve every 
>> byte you
>> can; a timestamp of "10/24/2001" or something similar is going to take 
>> 10
>> bytes as a string and an indeterminate number of bytes for an actual
>> timestamp because of system variations, whereas an integer value of 
>> 10242001
>> will take you 2-4 bytes depending on the type of int you declare.  Not 
>> a lot
>> of space, but assume for a second you have 30 fields in your database 
>> and 5
>> million rows...suddenly those 6-8 bytes have multiplied on this one 
>> field
>> alone.  Space and speed are important in DBs :)
>>
>> Mike Frazer
>
>
> --
> PHP Database 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 Database 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-DB] PHP and MySQL queries...

2001-10-25 Thread Tim Foster

I'm new to this list, to PHP and to MySQL (been doing VBScript on ASP for several 
years,
tho).

I'm curious...

If you're going to store it as an integer, why not store "10/24/2001" as MMDD
(20011024). This gives you the added benefit of being able to have the db sort your
fields. This even works if you want to include the time with your date (provided all 
dates
in the field consistently contain the same *amount* of info). For example, noon on
Christmas will always be lower than noon of the following New Year ..as it should be:

/MM/DD  20011225< 20020101
/MM/DD HH:MM200112251200< 200201011200
/MM/DD HH:MM:SS 2001122512  < 2002010112

I'm betting there's no easy way to sort it if you store it as MM/DD/YY

MM/DD/  10242001 < 12252001 (good)
..but NOT less than the following New Year's
MM/DD/  10242001 > 01012002 (bad)

Granted, you might take up a bit more space in the DB, which would have a tiny impact 
on
performance(??), but an extra $100 on the hard drive would effectively eliminate any
reasonable space considerations and (IMHO) reduce the amount of programming/debugging 
to
more than justify the overhead.

FWIW, M$ likes to store their dates as two integers: one to hold the date portion, the
other to hold the hours:minutes:seconds portion.

If there's something about PHP/MySQL that makes this point moot, please let me know.

TIM
-He who always plows a straight furrow is in a rut.


> -Original Message-
> From: Mike Frazer [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 24, 2001 7:54 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] PHP and MySQL queries...
>
>
> Agreed.  This is especially useful when you need to conserve every byte you
> can; a timestamp of "10/24/2001" or something similar is going to take 10
> bytes as a string and an indeterminate number of bytes for an actual
> timestamp because of system variations, whereas an integer value of 10242001
> will take you 2-4 bytes depending on the type of int you declare.  Not a lot
> of space, but assume for a second you have 30 fields in your database and 5
> million rows...suddenly those 6-8 bytes have multiplied on this one field
> alone.  Space and speed are important in DBs :)
>
> Mike Frazer


-- 
PHP Database 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-DB] RE: [PHP-DEV] Re: [PHP-DB] PHP and MySQL queries...

2001-10-24 Thread Robinson, Mike
Title: RE: [PHP-DEV] Re: [PHP-DB] PHP and MySQL queries...





In these days and times, conservation of a meg of disk
space is really not a consideration. Not the primary one anyway.
The data should be stored in a format such that the
storage itself and then retrieval can be executed with a
minimum of handling/intervention other than the required
sanity-checking.


I've found that a set of date/time select controls and storage
in a datetime field have been optimal. Insertion requires
no parsing or complex handling (just some gluing of array
elements) and retrieval with mysql's date-related functions
means I don't need to touch the data one bit to display
it in a meaningful way.


For me, having to parse information before insertion,
or after retrieval in order to display it, wastes far
more resources than storing dates in a format other than
an int.



 Mike Robinson
 IT / Developer - Toronto Star TV
 Phone: 416.945.8786
 Fax: 416.869.4566
 Email: [EMAIL PROTECTED]



> -Original Message-
> From: Mike Frazer [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 24, 2001 8:54 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: [PHP-DEV] Re: [PHP-DB] PHP and MySQL queries...
> 
> 
> Agreed.  This is especially useful when you need to conserve 
> every byte you
> can; a timestamp of "10/24/2001" or something similar is 
> going to take 10
> bytes as a string and an indeterminate number of bytes for an actual
> timestamp because of system variations, whereas an integer 
> value of 10242001
> will take you 2-4 bytes depending on the type of int you 
> declare.  Not a lot
> of space, but assume for a second you have 30 fields in your 
> database and 5
> million rows...suddenly those 6-8 bytes have multiplied on 
> this one field
> alone.  Space and speed are important in DBs :)
> 
> Mike Frazer
 




http://www.torontostartv.com - Webcasting & Production
http://www.tmgtv.ca - Hometown Television
http://www.thestar.com - Canada’s largest daily newspaper, The Toronto Star, online



-- 
PHP Database 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-DB] PHP and MySQL queries...

2001-10-24 Thread Mike Frazer

Agreed.  This is especially useful when you need to conserve every byte you
can; a timestamp of "10/24/2001" or something similar is going to take 10
bytes as a string and an indeterminate number of bytes for an actual
timestamp because of system variations, whereas an integer value of 10242001
will take you 2-4 bytes depending on the type of int you declare.  Not a lot
of space, but assume for a second you have 30 fields in your database and 5
million rows...suddenly those 6-8 bytes have multiplied on this one field
alone.  Space and speed are important in DBs :)

Mike Frazer



"Kodrik" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Why don't you let them enter it however they want in the form
> mm-dd-
> mm/dd/yy
>
> then in the php script that processes it, convert it with regulat
expressions
> to a timstamp and enter it in your database as an int. That's how I do it.
> I don't understand the point in using the mysql timedate field format.
>
> Then on retrieval form the db, php can easily convert it to a nice format
> with the date() function.
>
> > On Tue, 23 Oct 2001 10:52:41 -0600 Jason <[EMAIL PROTECTED]> wrote:
> > > I am having a hard time setting up a form for users to enter a date in
> > > the format of 00/00/ (of course they would use an actual date).
My
> > > form is as follows...
> > > 
> > >   *I.E. - Format is 04/01/2001*
> > >   Search for Ads by date:
> > > 
> > >   
> > >   
> > >  > > value="Submit">
> > >  > > value="Reset"> 
> > > 
> > > 
> > > On my search.php page I have the following MySQL connection and search
> > > parameters...
> > >  > >
> > > mysql_connect ("db_hostname", "db_username", "db_password");
> > >
> > > mysql_select_db ("db_name");
> > >
> > > if ($date == "")
> > > {$date = '%';}
> > >
> > > $result = mysql_query ("SELECT
> > >
fname,lname,address,city,state,zip,phonea,phone,email,crty,crnum,crmo,cry
> > >r,w eeks,ogden,rock,logan,ipaddress,ad,total,num,date,time
> > >   FROM ads WHERE date LIKE '%$date%' LIMIT 0, 30 ");
> > > $count = -1;
> > > if ($row = mysql_fetch_array($result)) {
> > > $count ++;
> > > do {
> > > echo "Name: ";
> > > printf(mysql_result($result,$count,"fname"));
> > > echo " ";
> > > printf(mysql_result($result,$count,"lname"));
> > > echo "\n";
> > >
> > > echo "Address: ";
> > > printf(mysql_result($result,$count,"address"));
> > > echo "\n";
> > >
> > > echo "City: ";
> > > printf(mysql_result($result,$count,"city"));
> > > echo "\n";
> > >
> > > echo "State: ";
> > > printf(mysql_result($result,$count,"state"));
> > > echo "\n";
> > >
> > > echo "Zip: ";
> > > printf(mysql_result($result,$count,"zip"));
> > > echo "\n";
> > >
> > > echo "Phone: (";
> > > printf(mysql_result($result,$count,"phonea"));
> > > echo ") ";
> > > printf(mysql_result($result,$count,"phone"));
> > > echo "\n";
> > >
> > > echo "Email: ";
> > > printf(mysql_result($result,$count,"email"));
> > > echo "\n";
> > >
> > > echo "Credit Type: ";
> > > printf(mysql_result($result,$count,"crty"));
> > > echo "\n";
> > >
> > > echo "Credit Number: ";
> > > printf(mysql_result($result,$count,"crnum"));
> > > echo "\n";
> > >
> > > echo "Credit Card Date: ";
> > > printf(mysql_result($result,$count,"crmo"));
> > > echo " ";
> > > printf(mysql_result($result,$count,"cryr"));
> > > echo "\n";
> > >
> > > echo "Weeks: ";
> > > printf(mysql_result($result,$count,"weeks"));
> > > echo "\n";
> > >
> > > echo "town1: ";
> > > printf(mysql_result($result,$count,"town1"));
> > > echo "\n";
> > >
> > > echo "town2: ";
> > > printf(mysql_result($result,$count,"town2"));
> > > echo "\n";
> > >
> > > echo "town3: ";
> > > printf(mysql_result($result,$count,"town3"));
> > > echo "\n";
> > >
> > > echo "IP Address: ";
> > > printf(mysql_result($result,$count,"ipaddress"));
> > > echo "\n";
> > >
> > > echo "Ad: ";
> > >
> > > $ad[$count] = (mysql_result($result,$count,"ad"));
> > >
> > > $ad[$count] = ereg_replace ("&a&", "'", $ad[$count]);
> > > $ad[$count] = ereg_replace ("&q&", "\"", $ad[$count]);
> > > $ad[$count] = ereg_replace ("&p&", "%", $ad[$count]);
> > > $ad[$count] = ereg_replace ("&bs&", "\\", $ad[$count]);
> > >
> > >
> > > echo $ad[$count];
> > > echo "\n";
> > >
> > > echo "Total: ";
> > > printf(mysql_result($result,$count,"total"));
> > > echo "\n";
> > >
> > > echo "Ad Number: ";
> > > printf(mysql_result($result,$count,"num"));
> > > echo "\n";
> > >
> > > echo "Date: ";
> > > printf(mysql_result($result,$count,"date"));
> > > echo "\n";
> > >
> > > echo "Time: ";
> > > printf(mysql_result($result,$count,"time"));
> > > echo "\n";
> > >
> > > } while($row = mysql_fetch_array($result));
> > >
> > > } else {print "Sorry, no records were found!";}
> > >
> > > ?>
> > > So far I 

Re: [PHP-DB] PHP and MySQL queries...

2001-10-24 Thread Kodrik

Why don't you let them enter it however they want in the form
mm-dd-
mm/dd/yy

then in the php script that processes it, convert it with regulat expressions 
to a timstamp and enter it in your database as an int. That's how I do it.
I don't understand the point in using the mysql timedate field format.

Then on retrieval form the db, php can easily convert it to a nice format 
with the date() function.

> On Tue, 23 Oct 2001 10:52:41 -0600 Jason <[EMAIL PROTECTED]> wrote:
> > I am having a hard time setting up a form for users to enter a date in
> > the format of 00/00/ (of course they would use an actual date).  My
> > form is as follows...
> > 
> >   *I.E. - Format is 04/01/2001*
> >   Search for Ads by date:
> > 
> >   
> >   
> >  > value="Submit">
> >  > value="Reset"> 
> > 
> > 
> > On my search.php page I have the following MySQL connection and search
> > parameters...
> >  >
> > mysql_connect ("db_hostname", "db_username", "db_password");
> >
> > mysql_select_db ("db_name");
> >
> > if ($date == "")
> > {$date = '%';}
> >
> > $result = mysql_query ("SELECT
> > fname,lname,address,city,state,zip,phonea,phone,email,crty,crnum,crmo,cry
> >r,w eeks,ogden,rock,logan,ipaddress,ad,total,num,date,time
> >   FROM ads WHERE date LIKE '%$date%' LIMIT 0, 30 ");
> > $count = -1;
> > if ($row = mysql_fetch_array($result)) {
> > $count ++;
> > do {
> > echo "Name: ";
> > printf(mysql_result($result,$count,"fname"));
> > echo " ";
> > printf(mysql_result($result,$count,"lname"));
> > echo "\n";
> >
> > echo "Address: ";
> > printf(mysql_result($result,$count,"address"));
> > echo "\n";
> >
> > echo "City: ";
> > printf(mysql_result($result,$count,"city"));
> > echo "\n";
> >
> > echo "State: ";
> > printf(mysql_result($result,$count,"state"));
> > echo "\n";
> >
> > echo "Zip: ";
> > printf(mysql_result($result,$count,"zip"));
> > echo "\n";
> >
> > echo "Phone: (";
> > printf(mysql_result($result,$count,"phonea"));
> > echo ") ";
> > printf(mysql_result($result,$count,"phone"));
> > echo "\n";
> >
> > echo "Email: ";
> > printf(mysql_result($result,$count,"email"));
> > echo "\n";
> >
> > echo "Credit Type: ";
> > printf(mysql_result($result,$count,"crty"));
> > echo "\n";
> >
> > echo "Credit Number: ";
> > printf(mysql_result($result,$count,"crnum"));
> > echo "\n";
> >
> > echo "Credit Card Date: ";
> > printf(mysql_result($result,$count,"crmo"));
> > echo " ";
> > printf(mysql_result($result,$count,"cryr"));
> > echo "\n";
> >
> > echo "Weeks: ";
> > printf(mysql_result($result,$count,"weeks"));
> > echo "\n";
> >
> > echo "town1: ";
> > printf(mysql_result($result,$count,"town1"));
> > echo "\n";
> >
> > echo "town2: ";
> > printf(mysql_result($result,$count,"town2"));
> > echo "\n";
> >
> > echo "town3: ";
> > printf(mysql_result($result,$count,"town3"));
> > echo "\n";
> >
> > echo "IP Address: ";
> > printf(mysql_result($result,$count,"ipaddress"));
> > echo "\n";
> >
> > echo "Ad: ";
> >
> > $ad[$count] = (mysql_result($result,$count,"ad"));
> >
> > $ad[$count] = ereg_replace ("&a&", "'", $ad[$count]);
> > $ad[$count] = ereg_replace ("&q&", "\"", $ad[$count]);
> > $ad[$count] = ereg_replace ("&p&", "%", $ad[$count]);
> > $ad[$count] = ereg_replace ("&bs&", "\\", $ad[$count]);
> >
> >
> > echo $ad[$count];
> > echo "\n";
> >
> > echo "Total: ";
> > printf(mysql_result($result,$count,"total"));
> > echo "\n";
> >
> > echo "Ad Number: ";
> > printf(mysql_result($result,$count,"num"));
> > echo "\n";
> >
> > echo "Date: ";
> > printf(mysql_result($result,$count,"date"));
> > echo "\n";
> >
> > echo "Time: ";
> > printf(mysql_result($result,$count,"time"));
> > echo "\n";
> >
> > } while($row = mysql_fetch_array($result));
> >
> > } else {print "Sorry, no records were found!";}
> >
> > ?>
> > So far I have come to the conclusion that the input from the user is
> > probably where my problem is because I am assuming it is taking the "/"
> > in the date they enter and doing something I don't want it to.  In any
> > event if someone could give me a clue as to how to resolve this issue it
> > would be greatly appreciated.
> >
> >
> >
> > --
> > PHP Database 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]
>
> #---#
>
>   "Believe nothing - consider everything"
>
>   Russ Michell
>   Anglia Polytechnic University Webteam
>   Room 1C 'The Eastings' East Road, Cambridge
>
>   e: [EMAIL PROTECTED]
>   w: www.apu.ac.uk/webteam
>
>   www.theruss.com
>
> #---#

-- 
PHP Database Mailing List (http://www.php.ne

Re: [PHP-DB] PHP and MySQL queries...

2001-10-24 Thread Russ Michell

How about using 3 select menus:

* One for the day called 'dayselect'
* One for the month called 'monthselect;
* One for the year called 'yearselect'

When you get the values from the selects to perform query's upon, re-arrange the order 
the dates 
come in:

In your form they'll be in the order: day,month,year
To perform queries into a MySQL DB re-arrange them:

$date = $yearselect . "-" . $monthselect . "-" . $yearselect;

HTH
Russ

On Tue, 23 Oct 2001 10:52:41 -0600 Jason <[EMAIL PROTECTED]> wrote:

> I am having a hard time setting up a form for users to enter a date in the
> format of 00/00/ (of course they would use an actual date).  My form is
> as follows...
> 
>   *I.E. - Format is 04/01/2001*
>   Search for Ads by date:
> 
>   
>   
>  value="Submit">
> 
>   
> 
> 
> On my search.php page I have the following MySQL connection and search
> parameters...
>  
> mysql_connect ("db_hostname", "db_username", "db_password");
> 
> mysql_select_db ("db_name");
> 
> if ($date == "")
> {$date = '%';}
> 
> $result = mysql_query ("SELECT
> fname,lname,address,city,state,zip,phonea,phone,email,crty,crnum,crmo,cryr,w
> eeks,ogden,rock,logan,ipaddress,ad,total,num,date,time
>   FROM ads WHERE date LIKE '%$date%' LIMIT 0, 30 ");
> $count = -1;
> if ($row = mysql_fetch_array($result)) {
> $count ++;
> do {
> echo "Name: ";
> printf(mysql_result($result,$count,"fname"));
> echo " ";
> printf(mysql_result($result,$count,"lname"));
> echo "\n";
> 
> echo "Address: ";
> printf(mysql_result($result,$count,"address"));
> echo "\n";
> 
> echo "City: ";
> printf(mysql_result($result,$count,"city"));
> echo "\n";
> 
> echo "State: ";
> printf(mysql_result($result,$count,"state"));
> echo "\n";
> 
> echo "Zip: ";
> printf(mysql_result($result,$count,"zip"));
> echo "\n";
> 
> echo "Phone: (";
> printf(mysql_result($result,$count,"phonea"));
> echo ") ";
> printf(mysql_result($result,$count,"phone"));
> echo "\n";
> 
> echo "Email: ";
> printf(mysql_result($result,$count,"email"));
> echo "\n";
> 
> echo "Credit Type: ";
> printf(mysql_result($result,$count,"crty"));
> echo "\n";
> 
> echo "Credit Number: ";
> printf(mysql_result($result,$count,"crnum"));
> echo "\n";
> 
> echo "Credit Card Date: ";
> printf(mysql_result($result,$count,"crmo"));
> echo " ";
> printf(mysql_result($result,$count,"cryr"));
> echo "\n";
> 
> echo "Weeks: ";
> printf(mysql_result($result,$count,"weeks"));
> echo "\n";
> 
> echo "town1: ";
> printf(mysql_result($result,$count,"town1"));
> echo "\n";
> 
> echo "town2: ";
> printf(mysql_result($result,$count,"town2"));
> echo "\n";
> 
> echo "town3: ";
> printf(mysql_result($result,$count,"town3"));
> echo "\n";
> 
> echo "IP Address: ";
> printf(mysql_result($result,$count,"ipaddress"));
> echo "\n";
> 
> echo "Ad: ";
> 
> $ad[$count] = (mysql_result($result,$count,"ad"));
> 
> $ad[$count] = ereg_replace ("&a&", "'", $ad[$count]);
> $ad[$count] = ereg_replace ("&q&", "\"", $ad[$count]);
> $ad[$count] = ereg_replace ("&p&", "%", $ad[$count]);
> $ad[$count] = ereg_replace ("&bs&", "\\", $ad[$count]);
> 
> 
> echo $ad[$count];
> echo "\n";
> 
> echo "Total: ";
> printf(mysql_result($result,$count,"total"));
> echo "\n";
> 
> echo "Ad Number: ";
> printf(mysql_result($result,$count,"num"));
> echo "\n";
> 
> echo "Date: ";
> printf(mysql_result($result,$count,"date"));
> echo "\n";
> 
> echo "Time: ";
> printf(mysql_result($result,$count,"time"));
> echo "\n";
> 
> } while($row = mysql_fetch_array($result));
> 
> } else {print "Sorry, no records were found!";}
> 
> ?>
> So far I have come to the conclusion that the input from the user is
> probably where my problem is because I am assuming it is taking the "/" in
> the date they enter and doing something I don't want it to.  In any event if
> someone could give me a clue as to how to resolve this issue it would be
> greatly appreciated.
> 
> 
> 
> -- 
> PHP Database 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]
> 

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam

  www.theruss.com

#---#


-- 
PHP Database 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-DB] PHP and MySQL queries...

2001-10-23 Thread Jason

I am having a hard time setting up a form for users to enter a date in the
format of 00/00/ (of course they would use an actual date).  My form is
as follows...

  *I.E. - Format is 04/01/2001*
  Search for Ads by date:

  
  


  


On my search.php page I have the following MySQL connection and search
parameters...
Name: ";
printf(mysql_result($result,$count,"fname"));
echo " ";
printf(mysql_result($result,$count,"lname"));
echo "\n";

echo "Address: ";
printf(mysql_result($result,$count,"address"));
echo "\n";

echo "City: ";
printf(mysql_result($result,$count,"city"));
echo "\n";

echo "State: ";
printf(mysql_result($result,$count,"state"));
echo "\n";

echo "Zip: ";
printf(mysql_result($result,$count,"zip"));
echo "\n";

echo "Phone: (";
printf(mysql_result($result,$count,"phonea"));
echo ") ";
printf(mysql_result($result,$count,"phone"));
echo "\n";

echo "Email: ";
printf(mysql_result($result,$count,"email"));
echo "\n";

echo "Credit Type: ";
printf(mysql_result($result,$count,"crty"));
echo "\n";

echo "Credit Number: ";
printf(mysql_result($result,$count,"crnum"));
echo "\n";

echo "Credit Card Date: ";
printf(mysql_result($result,$count,"crmo"));
echo " ";
printf(mysql_result($result,$count,"cryr"));
echo "\n";

echo "Weeks: ";
printf(mysql_result($result,$count,"weeks"));
echo "\n";

echo "town1: ";
printf(mysql_result($result,$count,"town1"));
echo "\n";

echo "town2: ";
printf(mysql_result($result,$count,"town2"));
echo "\n";

echo "town3: ";
printf(mysql_result($result,$count,"town3"));
echo "\n";

echo "IP Address: ";
printf(mysql_result($result,$count,"ipaddress"));
echo "\n";

echo "Ad: ";

$ad[$count] = (mysql_result($result,$count,"ad"));

$ad[$count] = ereg_replace ("&a&", "'", $ad[$count]);
$ad[$count] = ereg_replace ("&q&", "\"", $ad[$count]);
$ad[$count] = ereg_replace ("&p&", "%", $ad[$count]);
$ad[$count] = ereg_replace ("&bs&", "\\", $ad[$count]);


echo $ad[$count];
echo "\n";

echo "Total: ";
printf(mysql_result($result,$count,"total"));
echo "\n";

echo "Ad Number: ";
printf(mysql_result($result,$count,"num"));
echo "\n";

echo "Date: ";
printf(mysql_result($result,$count,"date"));
echo "\n";

echo "Time: ";
printf(mysql_result($result,$count,"time"));
echo "\n";

} while($row = mysql_fetch_array($result));

} else {print "Sorry, no records were found!";}

?>
So far I have come to the conclusion that the input from the user is
probably where my problem is because I am assuming it is taking the "/" in
the date they enter and doing something I don't want it to.  In any event if
someone could give me a clue as to how to resolve this issue it would be
greatly appreciated.



-- 
PHP Database 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]