Jump to content

jarvis

Members
  • Posts

    543
  • Joined

  • Last visited

Everything posted by jarvis

  1. Hi, Sorry, me again! Ok, so i've got my url: http://www.mydomain.com/?ec3_after=2010-08-01&ec3_before=2010-08-07 I've then got the following code to get the values: $afterDateParts = split("-", $_GET['ec3_after']); $after = $afterDateParts[2] . " " . $afterDateParts[1] . " " . $afterDateParts[0]; echo $after; which returns: 01 08 2010 (correct for this demo) I've then got this to convert the above into a nicer format: $convertMe = strtotime($after); echo date('d-M-Y', $convertMe); But it always returns: 01 Jan 1970 For the love of god, I cannot work out why. Is it really not that simple? :'( Please someone put me out my misery. I'm loosing hair by the minute! Lol TIA
  2. Hi, I'm trying to alter the code below. It cuurently finds the start and end date of this week, no matter what day you're on. What I now need is to find the start & end date of next week, again, no matter what day you're on of this week Thanks to aleX_hill for the following code: <?php #THIS WEEK $dayOfWeek = date("w"); #The number of the day of the week. Sun = 0, Sat = 1 $todayDayOfMonth = date("d"); #The day of the month $thisMonth = date("m"); #The number of this month. Jan = 1, Dec = 12 $firstDayOfWeek = $todayDayOfMonth - $dayOfWeek; #The day of the month for the beginning of the week (Sun) if($firstDayOfWeek < 1) #The beginning of the week was in the previous month { $monthBeginWeek = $thisMonth - 1; $firstDayOfWeek = $firstDayOfWeek + date("t",mktime(0,0,0,$monthBeginWeek,1,date("Y"))); } else { $monthBeginWeek = $thisMonth; } $lastDayOfWeek = $todayDayOfMonth + (6 - $dayOfWeek); #Get the day of the month of the end of the week (sat) if($lastDayOfWeek > date("t")) #if the day of the month is larger then the number of days in the month { $monthEndWeek = $thisMonth + 1; $lastDayOfWeek = $lastDayOfWeek - date("t"); #Then take the number of days in the week to get the day number of the next week } else { $monthEndWeek = $thisMonth; } $start_of_week = date("Y-m-d",mktime(0,0,0,$monthBeginWeek,$firstDayOfWeek,date("Y"))); #echo $start_of_week; $end_of_week = date("Y-m-d",mktime(0,0,0,$monthEndWeek,$lastDayOfWeek,date("Y"))); #echo $end_of_week; ?> Any help is much appreciated! TIA
  3. Thanks mjdamato and again to aleX_hill. The reason I'm using this code is to locate the next month. However, if you're in December, the next month is January, so I also need to take the year into consideration. This all stems from passing date criteria into a query string, to allow people to search information by this week, next week and next month etc Hope this helps explain why I'm using this code. Thanks again
  4. Thanks aleX_hill, Something as smiple as if ($nextMonth > 12) { $year2 = date("o") + 1; echo $year2; } else { $year2 = date("o") ; echo $year2; } I think this will do the job nicely!?
  5. Thanks PFMaBiSmAd but I'm not too sure what you mean :-( sorry
  6. Thanks to aleX_hill and RussellReal for the help so far. I'm trying to utilise the code before to find the next month. However, it needs to be used with the current year. So I altered the below <?php $nextMonth = date("m") + 1; $daysInNextMonth = date("t",mktime(0,0,0,$nextMonth)); echo $daysInNextMonth;?> to #NEXT MONTH $nextMonth = date("m") + 1; echo $nextMonth; $daysInNextMonth = date("t",mktime(0,0,0,$nextMonth)); echo $daysInNextMonth ; $year = date("o"); echo $year; I can then pass it into my url query like so: <a href="<?php echo $url_path; ?>after=<?php echo $year; ?>-<?php echo $nextMonth; ?>-01&before=<?php echo $year; ?>-<?php echo $nextMonth; ?>-<?php echo $daysInNextMonth; ?>">Next Month</a> Brilliant I thought, until it comes to December 2010, the next month needs to be January 2011. Now I'm bamboozled. How do I get around this one? Many thanks, your help is always appreciated!
  7. Hi Guys, RussellReal, your code seems to get around the 30 days issue. One quick question. you need to use the date("m") within the code, which means if you echo out $nextMonth = date("m") + 1; echo $nextMonth; It says 8 rather than August. How do I then convert the 8 into August? If I change the "m" to "F" it stops the code working. Sorry to sound such a noob!
  8. Hi, Thanks for the replies. I'm developing & testing locally but using a live server. Anything date wise I test locally as it means I can check code works by altering my PC clock. Will try the above, thanks once again, it's very much appreciated!!!
  9. Thanks again aleX_hill but I still have an issue with the days in the month! If I alter my PC clock it says the next month is August and 30 days - which is wrong as should be 31. Equally, if I alter my PC clock to August, the next month is then September and this is then correct. It's like it's stuck on 30 days now the code has been changed. Sorry to be a pain!
  10. Hi Sorry, I'm having trouble with the code: $thisMonth = date("m"); //gets the 2 digit expression of the current month if($thisMonth == 12) //If we are in Dec { $nextMonth = "01"; //Make the next month Jan } else { $nextMonth = $thismonth + 1; //Otherwise add one the the current month } $daysInNextMonth = date("t",mktime(0,0,0,$nextmonth,1,date("Y"))); //set the time to the 1st of the next month of the current year (as the only time that the number of days change is in Feb, using current year is OK echo $daysInNextMonth; The above alwyas returns 31 days in the next month, even if you're in August, it says Sept has 31. Have I done something wrong? Thanks
  11. Duplicate posting as page timed out
  12. Thanks aleX_hill I think that answers my question. I'll go play with the code & see what I can do. Thanks again!
  13. Thanks aleX_hill but how do I get the 1st day of the month? Also, I'm still battling with how to get the start and end of a week no matter which day of the week you're on. many thanks
  14. Hi All, I'm trying to work out 2 date functions but am having trouble, hope fully, someone can help me out: 1) To work out the next month and how many days there are. need it to be able to say July | 1st August - 31st August 2) To do a 'this week' option. Starting the week on a Monday. So I can say today is Wednesday (for example) W/c Monday 26 July - 1st August Any help is much appreciated! Thanks in advanced
  15. Thank you, that's great! Dont like to just use these things. Cheers
  16. Thanks Shawn, How does this work strtotime('+7 days')); does it know to check whether you're inside 30 or 31 days, i.e. what happens if you're on the 28th of the month? Cheers
  17. Hi All, I've got the following URL: http://www.mydomain.com?ec3_after=2010-07-21&ec3_before=2010-07-22 This then returns a list of results after todays date but before 7 days time. Unfortunately, this is hard coded and I'd like to make it dynamic. How the hell can I get todays date and pass it into the above? Was thinking something like: $start_today = date('Y m d'); $end_date = ''; http://www.mydomain.com?ec3_after=<?php echo $start_date; ?>&ec3_before=<?php echo $end_date; ?>& However, I can't work out how to add the - in the date. I also can't work out how to add 7 days, adding 7 wont work as you need to know which month as to which date the month ends on. Any help is much appreciated! Many thanks in advanced!
  18. Hi All, Building a site with wordpress and want to show which page your on with the nav, as such the following code works: <?php foreach(get_pages('childof=0') as $p) { if($p->post_parent == 0) { $lc = ($p->ID == $wp_query->post->ID) ? ' class="active"' : ''; echo '<li><a href="'.get_permalink($p->ID).'" title="'.$p->post_title.'"'.$lc.'>'.$p->post_title.'</a></li>'; } } ?> Problem is, it's stopped the page order plug in I use working and just lists the pages automatically in alphabetical order. Is there any way I can alter the above to stop this? Thanks
  19. Ok using your sql worked, however, I need to use it as a replacement to the below: $images_query = 'SELECT categories.category_id, categories.category, thumbs.file_name, thumbs.image_description, uploads.file_name, uploads.image_description FROM (categories INNER JOIN thumbs ON categories.category_id = thumbs.category_id) INNER JOIN uploads ON thumbs.thumb_id = uploads.upload_id WHERE categories.category_id = '.$row['category_id']; As soon as I try adding in the category id part, it bombs the query with the error above???? thanks
  20. Thanks DavidAM, if i use SELECT thumbs.thumb_id, thumbs.file_name, uploads.upload_id, uploads.file_name FROM thumbs JOIN uploads on thumb_id = upload_id WHERE categories.category_id =19 I get the following error Unknown column 'categories.category_id' in 'field list' have I used your query incorrectly? Thanks
  21. Hi all, Hope someone can help. I've got the following query but it's returning the wrong result! Code: SELECT categories.category_id, categories.category, thumbs.file_name, thumbs.image_description, uploads.file_name, uploads.image_description FROM ( categories INNER JOIN thumbs ON categories.category_id = thumbs.category_id ) INNER JOIN uploads ON thumbs.thumb_id = uploads.upload_id WHERE categories.category_id =19 Although the above query works, the file_name is incorrect. It's pulling the right name for the thumbs.filename but not for uploads.file_name, this leads me to think it's the wau the uploads table is joined but I cannot see for looking! I have 4 tables Categories Code: CREATE TABLE IF NOT EXISTS `categories` ( `category_id` tinyint(3) unsigned NOT NULL auto_increment, `category` varchar(255) collate latin1_german2_ci NOT NULL default '', `cat_type` enum('0','1') collate latin1_german2_ci NOT NULL default '0', PRIMARY KEY (`category_id`) ) Category associations Code: CREATE TABLE IF NOT EXISTS `category_associations` ( `ca_id` smallint(4) unsigned NOT NULL auto_increment, `upload_id` tinyint(3) unsigned NOT NULL default '0', `category_id` tinyint(3) unsigned NOT NULL default '0', `date_submitted` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `approved` char(1) collate latin1_german2_ci NOT NULL default 'N', PRIMARY KEY (`ca_id`) ) Thumbs Code: CREATE TABLE IF NOT EXISTS `thumbs` ( `thumb_id` int(10) unsigned NOT NULL auto_increment, `category_id` int(10) unsigned NOT NULL default '0', `file_name` varchar(255) collate latin1_german2_ci NOT NULL default '', `file_size` int(6) unsigned NOT NULL default '0', `file_type` varchar(30) collate latin1_german2_ci NOT NULL default '', `image_description` varchar(255) collate latin1_german2_ci default NULL, `date_entered` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`thumb_id`), KEY `file_name` (`file_name`), KEY `date_entered` (`date_entered`) ) Uploads Code: CREATE TABLE IF NOT EXISTS `uploads` ( `upload_id` int(10) unsigned NOT NULL auto_increment, `category_id` int(10) unsigned NOT NULL default '0', `file_name` varchar(255) collate latin1_german2_ci NOT NULL default '', `file_size` int(6) unsigned NOT NULL default '0', `file_type` varchar(30) collate latin1_german2_ci NOT NULL default '', `image_description` varchar(255) collate latin1_german2_ci default NULL, `date_entered` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`upload_id`), KEY `file_name` (`file_name`), KEY `date_entered` (`date_entered`) ) A form is filled in, uploading a thumb and main image to a set category. The form handles multiple uploads. however, the query at the top seems wrong. Any ideas? TIA
  22. Solved used redirectBrowserToURL("http://www.domain.com/thanks.php"); Thanks
  23. Hi PFMaBiSmAd, Because of the way the site was constructed, I thought this would be the best way. The structure is: Header Page name, for example, index, about, thanks etc (which has several includes 1 being the enquiry form) Footer The enquiry form says thank you once you submit it, however, it would be better to fill in the form and send them to the thanks page. I thought header() was the only option to do this. If there is another way, I'm all ears! However, as this is a live site, I don't want to recode pages
  24. Like finding a needle in a haystack! I cannot see anywhere what could be causing this! I've an index.php which calls in header.php and quick_enquiry_form2.php Do I need to remove all spacing? Would it help if I posted the code? Thanks
  25. Thanks for the replies, the error says: Warning: Cannot modify header information - headers already sent by (output started at \inc\header.php:139) in \inc\quick_enquiry_form2.php on line 44 Line 139 in header.php is the navigation and line 44 of quick_enquiry_form2.php has no spacing and looks like [php $mailResult = @mail($to, $subject, $message, $headers); if (!$mailResult) { die("Mail Error: $php_errormsg"); } header("Location:thanks.php");[/code] There are also no spaces at the top of that file. Sorry, someone is gonna have to speak & spell it to me! :-(
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.