create one variable from multiple<

liunx

Guest
Hey
I want to create one variable from multiple ones in from a database.
So make from a row $year-$month-$day=ymd
or something like that.

an example of how to do it or where to read up on it would be great.

Thanks for any help!!$date = $year . $month . $day

creates a variable with the format YMDok, but the year month and day are from a database. So they would be fields from a database that need to be put into that format and then used in a query.
What I basically need is
Row - (year-month-day) => CURDATEhuh?

are you reading the information from the database, or trying to put the information in?

and why don't you just use a timestamp in the database?well i am pulling the year, month, and day from a database and putting it into a query to pull other data from the database.
And well i dont use a timestamp in my database cause i would think its a lot easier to enter in the date normally.Originally posted by SkaFreaks
ok, but the year month and day are from a database. So they would be fields from a database that need to be put into that format and then used in a query.
What I basically need is
Row - (year-month-day) => CURDATE
doesn't matter where it is coming from, Horus already answered your question.

$date = $year . $month . $dayi just dont see how thats gonna work, cause its not using the data from the database.hang on...

how is your date formatted in the database?

yyyy-mm-dd ?


(timestamps are easy - formatted as YYYYMMDD)


and it's formatted the same in both tables?

so why can you just take the 'yyyy-mm-dd' and write that directly into the next query?Originally posted by SkaFreaks
i just dont see how thats gonna work, cause its not using the data from the database.
you just said it right here

Originally posted by SkaFreaks
ok, but the year month and day are from a database. So they would be fields from a database that need to be put into that format and then used in a query.
What I basically need is
Row - (year-month-day) => CURDATE
then you need to exploded them at the "-" to put them back into a single variables.
(timestamps are easy - formatted as YYYYMMDD)
not all timestamps, php's not like that, it is the total seconds from 1970 I think.but he's talking about MySQL database where the dates are stored - so MySQL timestamps (8) are in that format.yes but you don't have to specifically use mysql's timestamp.1. i dont have the date stored as a date. i have it stored in three seperate columns, year, month & day.
2. I've tried using the (year-month-day)>=CURDATE
and that doesnt work. I've tried a few different ways of writing it too. Am I doing something wrong with it?if you want to query that kind of thing then you're going to be better off using MySQL timestamps (or at least all three in the one column).

Then you can perfom the query as:

WHERE Date >= date("Ymd");


which will test a YYYYMMDD against the returned info from the php date function.not really. if you were going to use mysql timestamp you might as well leave it all to mysql. and that is what he is doing. he used curdate() which is mysql. even if you used php's timestamp you can use all mysql functions to get the date correct.ok, the thing with storing the date all together is that other people will be using a form to enter the date which they enter the year, month & day seperate so they go into seperate columns.than tha tis fine, but have you figured out how to do it? make it one variable?no, i still cant get it to workshow us how you are taking it out of the db.I've tried:

$result = mysql_query("SELECT * FROM nuke_shows WHERE (year . month . day) >= CURDATE()",$db);
$result = mysql_query("SELECT * FROM nuke_shows WHERE (year-month-day) >= CURDATE()",$db);
$result = mysql_query("SELECT * FROM nuke_shows WHERE ((year)(month)(day)) >= CURDATE()",$db);

None have workedalso just tried all three of those with putting (Y-m-d) in the CURDATEthat doesn't even come close to what this thread is about. you can't do any of that that way.

well, I had something but with you splitting your dates up like that it messes things up.well crap.
ok, let me ask a different question then.
I have this code setup so I can ass, edit or delete rows from the database.

you might need to see the code for all this, but is there a way to have the form with a year, month and day and then combine them to equal fulldate and then insert that into a column?now that is what this thread is about

$date = $year . $month . $day

just as Horus said. or it they come from a drop down select and submitted

$date = $_POST['year'] . $_POST['month'] . $_POST['day'];

but you can always have timestamp in a column and let the db make the date. or you can have php make the date in a single column. so you are giving your users a chance to eidt it and pick the date?sweet. that works.

sorry about all the confusion with this topic and thank you for all the help!
 
Back
Top