some question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

some question

Post by rami »

patrikG | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


i have date field which accepts date in format 2004-12-15

what  i want is analysis taking out that month part or day part from that day 
(i dont want to keep separate day field ,month field, year field for that one thing)

so is there any way to tale out only month part ,day part


next i have seen like this in select

Code: Select all

<select...>
<option value=1>usa
<option value=2>uk....
or
in heights

Code: Select all

<select...>
<option value=1>5.5"
<option value=2>5.6"
actually i normally do

Code: Select all

<select...>
<option value='usa'>usa
<option value='uk'>uk....to insert it to database
how these people take know which match to which
if we use 'if else"
there will be lot of them and will be static
what they are doing...

i have dollar field some people do $100
but i am declaring it as int filed so $ is not allowed
is there any way if i declare varchar then only take out part ignoring that $


patrikG | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]2.[/b] Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.[/quote]
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Re: some question

Post by GM »

rami wrote:so is there any way to tale out only month part ,day part
In MySQL there are the YEAR(), MONTH() and DAYOFMONTH() functions

Code: Select all

SELECT YEAR(date_field) FROM table_name WHERE...
rami wrote: next i have seen like this in select
<select...>
<option value=1>usa
<option value=2>uk....

or
in heights
<select...>
<option value=1>5.5"
<option value=2>5.6"


actually i normally do
<select...>
<option value='usa'>usa
<option value='uk'>uk....to insert it to database

how these people take know which match to which
There is probably some database table that contains all the countries, with a numeric primary key. This way, you only store the number of the country in any records, and you don't have to keep repeating the name of the country (this would be redundant data).
rami wrote: i have dollar field some people do $100
but i am declaring it as int filed so $ is not allowed
is there any way if i declare varchar then only take out part ignoring that $
It is better to have a numeric field. (Probably you don't want it to be an integer field, since prices typically have a decimal point in them). What if in some future you want people to be able to see prices in Euros? A price is a numeric data, and so should have a numeric data type. In general it is bad practice to store things like currency symbols or units of measure in the same field as the data itself.
Post Reply