How Do You Select Everything After A Certain Date Please?
I want to select records from a MySQL database using PHP. I want to select all the records after 30th September. How do I do this, please?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Php Query To Select Min Date
im trying to get a minimum date from my database, the current way im doing it is: SELECT * FROM events where Date > NOW() OR Date = '9999-12-12' ORDER BY Date ASC LIMIT 1 this works in terms of code, but it doesnt do what I want it to do. Its the ORDER BY Date, that is the problem: What I want to select is The next date OR a date = 9999-12-12 I tried searching for a query like "select MIN date" but couldnt find anything on it, plus the date has to be in the future, hence the need for DATE > NOW() quite confusing I know!! but any advice?
SELECT DISTINCT And ORDER BY Date
I have a news site that allows users to add comments to articles, so I would like to show 10 recently commented stories in a side box. I am trying to use the following code ('sid' is article's id, 'date' is comment's date): $query="SELECT DISTINCT c.sid FROM comments c, articles a WHERE c.sid = a.sid ORDER BY c.date DESC LIMIT 10"; $result=mysql_query($query); while (list($sid) = mysql_fetch_row($result)) { $query2="SELECT date, title FROM comments WHERE sid=$sid ORDER BY date DESC LIMIT 1"; $result2=mysql_query($query2); list($date, $title) = mysql_fetch_row($result2); echo "$title - $date<br>"; } If there is one comment to each article, the box shows fine:
PHP "Calender Like" Pop Up To Select Date And Store As Variable In Mysql Format?
I use to have this feature on my site about two years ago when i hired someone. It would allow the user to select between two different dates, via a small calender, save it as a variable then query the database. Does anyone know where I can find the script for the small calender? I think it must of been populated by an external clock since all the dates were accurate etc. July 21st was on a saturday.
From Select To Date("Y-m-d",?)
I am going nuts here. I have 3 select forms for a birtday <select name="bmonth"> <select name="bday"> <select name="byear"> $birthday = date("Y-m-d",(int)$_POST['byear'].'-'.(int)$_POST['bmonth'].(int)$_POST['bday']); Date registerd is allways "1969-12-31" no matter what I select. Why?
Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution. So it goes <select name='status[]'>... <select name='resolution[]'> Then i have a another php page. $status = $_POST['status']; $resolution = $_POST['resolution']; Now my question is, how do i do the sql query statement? mysql_query("SELECT * from bugs where status=$status and resolution=$resolution"); The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.
Select Statement - Select Random ID #
I have made up a page that pull info on 13 branches of stores onto one main page. It's basically there to display all the branches on one page... then you click on the one you're interested in and then you go to a more detailed page. Back to the main page. On the top, there's kind of a featured branch that has a bigger picture and bigger title but it's still getting pul pulled from the same table etc etc etc. In order for me to avoid favortism to one branch (and for other branches to start complaining) I want to ramdomized the order every time someone came to page but I have no idea how. right now I have a super simple select statement.
Check Date From Input Must Greater Or Equal Today Date?
I have 3 select box. Code: <select name="day"> <option value="1">1</option> <option value="2">2</option> ....... <option value="31">31</option> </select> <select name="month"> <option value="01"> Jan </option> <option value="02"> Feb </option> ..... </select> <select name="year"> <option value="2002">2002 </option> <option value="2003">2003</option> </select> When I select and click submit in form. I will have 3 variable : $day, $month and $year How can I check the day that I choose in form must equal or greater than today date? If it less than today date. I must print error message to user.
Date Is Not Being Pulled From MYSQL Database, Instead Current Date Is Displayed!
I am having trouble pulling a date from a database using PHP at the <a href="http://www.mytuneslive.com/ameshkin69/"> following page.</a> Here is the code. As you can see, it is just making the date the current time. The values in the database are UNIX timestamp, and the DATE() function is used to convert from UNIX to readable date. Can <td width="55%" align="left" valign="top"><?php $row_comment['timestamp'] = date("n d Y g:i A");.....
Read Today's Date Print Tomorrow's Date
I've got a small script that writes a random number and the date to a text file. Then the script opens this text file and if date = date from this text file something must happen. If something happened this script must open this text file again and replace it with a new random number and tomorrow's date. <?php $date = date("d-m-Y"); mt_srand((double)microtime()*10000000000); $num=mt_rand(0, 20); if ($num == $num && $date == "$tomorrowdate") { echo"$num -- $date";} else echo " ";?> So if the script gets activated on the 05-05-2003 it must write tomorrow's date into the text file (06-05-2003). How will I get tomorrow's date today?
Help: Date Function Not Returning Correct Date & Time
I have just notices that the date() function is not returning the correct date/time on my "server". I am running apache2 on my winxp pro laptop. My system clock is set to the correct date, time and timezone, get the results returned by date() are 11 hours behind.
PHP Date Question: How To Determine The Date Each Of The Past 3 Sundays
How can I determine what the date was (in YYYY-MM-DD format) last Sunday, and the Sunday before that? For example: Today is Thursday, August 18, 2004 (2004-08-18). I would like to have the following variables: $this_past_sunday = 2004-08-14 $two_sundays_ago = 2004-08-07 $three_sundays_ago = 2004-07-31 etc. etc.
Save Date To Table Field Date Type
I have a calendar picker on a form that fills a text box with XX/XX/XXXX date format. If I run a insert statement the date field in the database shows 0000-00-00. If i change the field type to varchar the correct format displays. What is the correct way to save a date to a mysql database? Furthermore to query on the date how about a select * from db_name where servicedate >= $startdate and servicedate >= $enddate I supose this will not work Any pointers?
Date Dropdown From Mysql Date Entries
For the PHP gurus out there, here is what I want to do: create a dropdown list of available dates from a mysql database date entries. But the dropdown/s should have 3 separate fields in month, day and year which in effect shows only those months, days and years that have corresponding entries from the database. Planning to use this in the archive section of an online news publication so people can select issues to view via dropdown list that have corresponding entries only.
Start Date - End Date = Number Of Days
I have a starting date for var 1 and today’s date for var 2. I need to calculate how many days are between those two dates. 02/24/03(today) - 01/14/2002(start date) = number of days. In theory this is easy but there are many instances were I could get an inaccurate answer. For example one consideration is that some months have 30 days others have 31. exc. My question is, is there an easier way to solve this problem other than using endless if statments to error handle all possible instances? Does PHP4 have any built in functions that could calculate this formula correctly?
UNIX Mktime To MySQL Date Or Date
A form that sends a starting date and an ending date. I have figured out how to tell the difference between the two and even rip the difference into an array because I need to compare the individual dates against a mySQL database to pull results from a particular date in a series. This is no problem. My problem is that teh mySQL database uses DATE as a field definition and this can not be changed. I managed to pull the date differences using some cleaver mktime stuff but no I do not know how to get this 1072242000 into this 2003-12-24... Is there a function that reverses the mktime result into a usable date format? I would take anything at this point and I can explode and then array it to get what I want - but there has to be something. Code:
Formatting Date From MYSQL Date Field
i've got a date field in my table, but the default format is YYYY-MM-DD... is there any way i can pull the date out of the database and format it differently... like DD.MM.YYYY or like April 13, 2003?
Counting Days From $date To Current Date
how to count the time between two variable dates? Such as someone inputting 6/8/1991 in a form and it comparing that to todays date... then getting the number of seconds elapsed... I know I have to use the mktime() function to get the seconds.. but not quite sure how.
Date() Gives Me Yesterday's Date And Not Today's - Why?
$result[$i]->record_entered contains the current date as set up by MySQL (entered as "now()"). I verified that in the database the date is "now()", which in this case will be "2/9/2006". However, when viewing the page using the display: Code: ( php )
Begin Date And End Date, But No Weekends!
I am making a system to plan my work days. If i begin on a project on 01-10-2007, and the project is 100 hour and i work 10 hours a day, it will cost 10 days for me too work. The answer is simple, project is done @ 10-10-2007, but i dont work in the weekend. So it must be 12-10-2007, i got the following script;, but it aint working right. Because when the begin date and end date is more then 2 weeks, and more than 2 weekends, it doenst count the weekends good. Can someone help me, or is there somebody with a better solution? I am working two days on it, but i cant get it right <?php $begin_date = strtotime( date( '2007-10-01' ) ); $hours = 100; $workdays = 10; $total_days = $hours / $workdays; $total_days *= (60 * 60 * 24); $weekend = $total_days / 7 * 2; $enddate = $begin_date + $total_days + $weekend; if( date('D', $enddate ) == 'Sat' ) { echo 'End date <b>' . date('d-m-Y', $enddate + (2*86400)) . '</b> 2 days<br /><br />'; } elseif( date('D', $enddate ) == 'Sun' ) { echo 'End date <b>' . date('d-m-Y', $enddate + (1*86400)) . '</b> 1 day<br /><br />'; } else { echo 'End date <b>' . date('d-m-Y', $enddate) . '</b><br /><br />'; } ?>
Date Conversions ( Date, Mktime )
I have a date in three pieces dd mm yyyy. I'm just wondering the best way to convert this for inserting into a DATETIME field and then back again when displaying it. I have tried date, strtotime mktime but it keeps inserting a blank date. i.e. 00:00:00 00:00... I've been looking through the php manual but I can't seem to get this working. Also would I be better off using the UNIX_TIMESTAMP function?
Check Date Is Not Before Current Date
I need to validate a date entered to make sure it isnt before the current date. I have managed to this in Javascript but not sure how to do this in PHP when the value is submitted.
Date Time Not Accurate For Date();
echo "date=".date('Y-m-d h:i:s'); date=2007-11-15 15:48:14 the clock is the accurate at here..showing only 3pm ..while now my pc showing 11.51pm(localtime)
Put Today's Date Into A MySQL "date" Formated Field
My MySQL table has a field that is set as type "date." I need to get today's date, and insert it into that field. The default for that MySQL field is 2006-00-00. I know about the date() function. I have tried date("Y-m-d") and date("U"), neither worked. The date field was just filed with all zeros. Can anybody point me in the right direction?
Date And System Date
I am currently looking for a way to compare the current system time date to a date that is in my database. PHP Code:
Change $row['date'] To $date
When writing the code to display the mysql_fetch_assoc results I'd like to remove the $row[''] portion and just leave it as a variable like this: $date, $numid, $text and on and on. For the life of me I can't remember how to do it... even though I know I looked at this last week sometime.
Start Date End Date
I am creating a simple auction site. There will be a start date which I think will be a timestamp and an end date. How can I do code the end date so that it is $days until it closes? I am not asking for code (although that may be helpful) I am asking for an explanation.
Date From And Date To Fields
I have a table which contains special offers starting from a certain date and ending at another date. Therefore would I just do $date = date("Y-m-d H:i:s "); SELECT * from Tablename WHERE start_date <= '$date' && end_date >= '$date' Is this correct?
SELECT *
If I have a lot of articles, all with a unique IDs. First I would like to search for that ID, I could do SELECT * from ARTICLE where ID = xx But I also want to display the 5 articles before and after that article. SELECT * from ARTICLE where ID > xx LIMIT 0, 10 and SELECT * from ARTICLE where ID < xx LIMIT 0, 10 (I choose a limit of 10 in case the ID is one of the first one or one of the last one, that way I will always have at least 10 articles). Is it possible to do the above in one single query? Should I even bother doing that? does it make the whole operation faster to do it that way?
Select Box
I have a problem that I'm not quite sure what algorithm will help me on. I'm bringing in records from MySQL using PHP and need to spit this records into a select box. Fairly simple, here's my code for the first select box: <option selected value="<?=$currentCatID?>"><?=$currentCategoryName?><option> <?php while($rowGetCat = mysql_fetch_array($resultGetCat)){ if($rowGetCat['pCatID'] != $currentCatID){ echo "<option value="".$rowGetCat['pCatID']."">".$rowGetCat['pCatName']."</option>"; } } ?> </select> Problem is - based on their choice with the first select box, I need to query the DB and populate a second select box. So basically, I need a 2nd select box that is populated on the fly based on their choice from the first select box. The only solutions I have found so far use their own form, and the form I have now has numerous other options and values that I need to save the state of for editing. I was thinking AJAX might help, or maybe just regular javascript, but without having the entire page reload I'm not sure.
Sub Select
I have this line of code: $result = mysql_query("SELECT jobnumber, projectname, description FROM timesheets WHERE description IN(SELECT distinct jobnumber, projectname FROM timesheets)",$db); But this returns nothing. What I want it to do is display the 3 fields jobnumber, projectname and description where the jobnumber,projectname combination is unique.
Select The Id And The Name
I have this code that when the user provide his email address he will participate in a raffle, my problem is that i want to select the id and the name but my selection is not workin Code:
Select From
Is there a way to select from multiple mysql tabels?
Value To Use To Select All
I have done the following query: $query = sprintf ("SELECT * FROM users WHERE country LIKE '$selCountry'"); $result = mysql_query($query,$link); I want to obtain the users that are from a certain country but when $selCountry is equal to "All" I want to obtain all of them. I have tried the query in mysql webpage using '%' and it works but when using this character from the php file it doesn't work.
SELECT *
What would I have to put within the $sort variable to have that request display all rows starting with a number? right now I have to put 1,2,3,4,5,6,7,8,9 seperate. Anyway I can include it all in one variable that would work below? $q = 'SELECT * ' . ' FROM `company_details` ' . ' WHERE `cname` LIKE '' . $sort . '%'' . ' ORDER BY `cname` ASC'; $r = mysql_query($q);
SELECT MAX()
$f1 = mysql_query("SELECT MAX(id) FROM topics WHERE fid = '$f'"); $f2 = $f1+1; now, I can't see any errors...but when I ran my code $f2 should have equalled 4, but somehow it came out with 12? what's wrong with it??
Select Box
I have a select box coded that displays MySQL data as options in the pull down menu. What I need to know is if and how I can make it so that each option has given background. Can I assign a class to each option? The code for my select box looks like this: Code:
<select>
I have a query regarding <select> name: The script runs through a for loop for each select which gets the qty's from the DB, so the user can only select the maximum thats available in stock. Each select is given a name, which is the record ID from the DB ($wsi_id_arr[$num]). So the first select will be <select name="VB001"> for example. However, the problem i am having is how do I get at this in another script, for example, so far I have: for($ordercnt=0;$ordercnt<$num;$ordercnt++) { if(...................
Cannot Pass @ For A SELECT... WHERE
From a cycling database, to put to screen the Clubs whose Secretary has email, this works just fine in phpMyAdmin - select email from clubs where email like "%@%" order by club I want to do it in php but from the manual and these DevShed files, it seems the @ character stops all further progress along the line it's on???? I've tried all kinds'v variations of the following, brackets on and off, double and single quotes, till I'm blue in the face.
Help With Select Count In PHP
I'm trying to do a script that tells me how many orders I got in on a particular day. The script loads, but nothing shows up. Any help would be greatly appreciated! Here it is: <? //create connection $connection = mysql_connect (localhost, xxxxxx, xxxx) or die ("Couldn't connect to server."); // select database // substitute your own database name $db = mysql_select_db (MyDB, $connection) or die ("Couldn't select database."); $date = "02/05/02"; // create SQL statement $sql = "SELECT COUNT(*) FROM CUSTOMER as mycount WHERE CREATED='$date' AND STATUS=Ɔ'"; // execute SQL query and get result $sql_result = mysql_query($sql,$connection) or die ("Couldn't execute query."); //start results formatting echo "<br><br><div align=center>"; echo "<table cellpadding=5 cellspacing=0 width=ྛ%'>"; echo "<tr bgcolor='#336699'> <td width=100% valign=top><font face='verdana,arial,helvetica' size='-2' color='#ffffff'><b>Orders Today:</b></font></td> </tr>"; // format results by row while ($row = mysql_fetch_array($sql_result)) { $mycount = $row["mycount"]; echo "<tr> <td width=100% valign=top><font face='verdana,arial,helvetica' size='-2' color='#000000'>$mycount</font></td> </tr>"; } echo "</table>"; echo "</div>"; /free resources and close connection mysql_free_result($sql_result); mysql_close($connection); ?>
Select The First Letter
I'm trying to do a query, but i want the query to be done using only the first letter of the values in lname. ("SELECT * from wisdom where lname == '$letter' "); "Letter" is the value that i want generated coming from the previous page. I want all the data from lname with A as the first letter selected so i can display them.
MySQL Select
Just a qucik question. I need to display everything from the table where the data is not null, apart from username, as they'll always have a username. So far I just have this, which is on the assumption they have entered their name. $get = "SELECT * from profiles WHERE name IS NOT NULL LIMIT 30"; Is there a way I can basically make it say. Select * from profiles where * but username is NOT NULL?
Select Value In A Table
In my sql table I've a list of colors: white, blue, green..... table colors: idcolor, coloname 1, white 2, blue 3, green..... I've some programs sending colors for some material, but I don't want to use them, I'd like to use my values: example: program gives 'dark blue' then I'd like to select blue in my table and...
|