LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-24-2003, 07:33 PM   #1
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Rep: Reputation: 31
Get the date on PHP and insert it into SQL


Hello:

I'm creating a little database in a store. I need that when someone "sells" something, it stays in a table , the name of the guy who sold it, what was sold etc.... I have all that, but I don't know how to save the date it all happened.

I have the table with the following atributes (or columns)

Vendor, Article, Date, Quantity.

Vendor article and quantity are int (just id's) and Date is a DATE type.
how can I get it from the computer? afterwords, if I want to make a search based on the date, will I have to write all of it ( as 12-3-200)?

Thanks
 
Old 11-25-2003, 05:16 AM   #2
BlackT
LQ Newbie
 
Registered: Jul 2003
Distribution: Mandriva LE 2005
Posts: 18

Rep: Reputation: 0
It's simple...when you insert into db, use this for date:

"INSERT INTO .... SET Vendor = "...", ...., Date = NOW()

When you want to search for records by date, use something like:

"SELECT ... FROM ... WHERE ..... AND TO_DAYS(Date) - TO_DAYS('[your search date here]') = 0"

HTH
 
Old 11-25-2003, 06:37 PM   #3
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Original Poster
Rep: Reputation: 31
thanks a lot!!!!! by the way, would you happen to know how to load a page with php, lets say. I receive a name in a text field and if that name is "poeta" php checks it and send me to poeta.html, else it will send me to other.html.

Thanks
 
Old 11-26-2003, 03:23 AM   #4
BlackT
LQ Newbie
 
Registered: Jul 2003
Distribution: Mandriva LE 2005
Posts: 18

Rep: Reputation: 0
PHP Code:
if($name == "poeta")
   
header("location:poeta.html");
else
   
header("location:other.html"); 
This is a simple redirect conditioned by the variable $name...


HTH
 
Old 11-26-2003, 03:25 AM   #5
BlackT
LQ Newbie
 
Registered: Jul 2003
Distribution: Mandriva LE 2005
Posts: 18

Rep: Reputation: 0
Well, it's:

header("Location : poeta.html");

and

header("Location : other.html");

Just don't use space between "Location", ":" and "poeta..." or "other..."
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert date and timestamp Into File name petenyce Linux - Newbie 9 10-13-2005 12:16 PM
Insert problem Php petenyce Linux - Newbie 1 10-12-2005 02:52 PM
PHP insert. agallant Programming 4 08-17-2004 02:36 PM
SQL insert using a non-locking trigger acid_kewpie Programming 0 07-13-2004 05:38 PM
Error: Acct: Couldn't insert SQL accounting START record - Duplicate entry '15212' fo ethanchic Linux - Software 0 04-11-2003 10:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration