PHP - Simple Date Passing In Querystring
the ultimate goal is to let the user select to date range (begin date in DD-MM and enddate in DD-MM), pass this through php file with ajax and query it against the registered date (stored as a datetime),
however i'm already running problems catching the values of minDate and maxDate. Can sombody tell me what's wrong please? Code: [Select] if (document.getElementById('brdat_dag').value != ''){ var minDag = document.getElementById('brdat_dag').value;} if (document.getElementById('brdat_maand').value != ''){ var minMaand = document.getElementById('brdat_maand').value; } var minDate = date ('Y-m-d H:i:s', mktime (0,0,0,minMaand,minDag.value,date('Y', time()))); var queryString = "?postcode=" + postcode + "&provincie=" + provincie + "&aland=" + aland + "&gland=" +gland +"&minAge=" + minAge +"&maxAge=" + maxAge + "&sex=" + sex; + [color=red]"&minDatum=" + minDatum;[/color] Similar TutorialsHi I have a problem i need some help with, when passing values from my Results page to my Details page through a URL is the Querystring different because i have INNER JOINED 2 tables? This is my Querystring <a href="DetailsPet.php?id=<?php echo $row_ResultsRS['id']; ?>">Details</a></td> i have 2 tables (petdata and customerdata) and there INNER JOINED using the 'id' But its not passing on the values, and just shows the 1st results in database all the time. Im only just learning Php, but would i be right in thinking it to do with the 'id' as this is what joins the 2 tables. Do i have to state which 'id' to use? if so how do i do it? Thanks willo Hi there, I've just started learning php and mysql today. I'm putting things together in dreamweaver and everything is running smoothly (ish). I've got a form written in php that sends data to a database. All fine. I need to send the time of submission to the database. I've put in a hidden field, what code should I use to set the field value to a mysql field of type DATETIME? Cheers. Code: [Select] function display_details($name, $department="sales", $sex="male") { return "You are {$name} from {$department} and you are {$sex}"; } I need to use the default value for $department, but none of the below work. How do I do it? echo $display_details("Sally", NULL, "female"); // sets $department as empty/blank echo $display_details("Sally", "", "female"); // sets $department as empty/blank echo $display_details("Sally", , "female"); // PHP error This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=355809.0 I need to work out the months remaining of someone's membership when the date provied is in the format dd/mm/YYYY - rounded down to one month. So, today being Nov 6th if the membership expired on 10th Feb then this would return 3. 1st Feb would be 2 etc.. Hi: How can I build a querystring (or whatever I need to do to solve my issue) to pull in the month and year? Meaning: I have this link: Code: [Select] Entertainment.php which goes to a dynamic calendar, which works fine except it does not show the events because I think it replies on getting the current month and year. When I click on a "Next Month" and the click back to the current month, the URL is: Code: [Select] Entertainment.php?month=4&year=2011 and the events then display properly in the calendar. How do I properly build a URL for this? The calendar code looks like this: Code: [Select] <?php ob_start(); $today = date("M Y"); ?> ... <head> <script> function show_evt(m,y,day){ location.href = "<?=$_SERVER['PHP_SELF'];?>?month=" + m + "&year=" + y + "&day=" + day; } function goLastMonth(month, year) { if(month == 1) { --year; month = 13; } document.location.href = '<?=basename($_SERVER['PHP_SELF']);?>?month='+(month-1)+'&year='+year; } function goNextMonth(month, year) { if(month == 12) { ++year; month = 0; } document.location.href = '<?=basename($_SERVER['PHP_SELF']);?>?month='+(month+1)+'&year='+year; } </script> </head> ... <p> <?php $date =time (); $day = (isset($_GET['day'])) ? $_GET['day'] : date('d', $date); $month = (isset($_GET['month'])) ? $_GET['month'] : date('m', $date); $year = (isset($_GET['year'])) ? $_GET['year'] : date('Y', $date); $first_day = mktime(0,0,0,$month, 1, $year); $title = date('F', $first_day); $day_of_week = date('D', $first_day); switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } $days_in_month = cal_days_in_month(0, $month, $year); ?> <table class="tableClass"> <tr class="field-bg-color"> <th class="eventLeftArrow"><a href="javascript: void(0);" onClick="goLastMonth(<?php echo $month . ", " . $year; ?>)"><<<</a></th> <th colspan="5" class="eventHeader"><?=$title. " " . $year;?></th> <th class="eventRightArrow"><a href="javascript: void(0);" onClick="goNextMonth(<?php echo $month . ", " . $year; ?>)">>>></a></th> </tr> <tr class="calDates"> <td>S</td> <td>M</td> <td>T</td> <td>W</td> <td>T</td> <td>F</td> <td class="lastOne">S</td> </tr> <?php $day_count = 1; ?> <tr> <?php while ( $blank > 0 ) { ?> <td> </td> <?php $blank = $blank-1; $day_count++; } $day_num = 1; while ( $day_num <= $days_in_month ) { $sql = "select count(calName) as evt_count from calTbl where calDate ='" . $month . '/' . $day_num . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ if($row['evt_count'] >= 1){ ?> <td align="center" style="cursor:hand;cursor:pointer;background-color:#FF6A6A;text-align:center;" onclick="show_evt('<?=$month;?>','<?=$year;?>','<?=$day_num;?>');"> <div class="brown-bg-color cal-head-text white-text bold-text"><?=$day_num;?></div> <?php $sql = "select * from calTbl where calDate ='" . $month . '/' . $day_num . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ ?> <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$month;?>&year=<?=$year;?>&day=<?=$day_num;?>"><?=$row['calName'];?></a></br> <? } }else{ ?> <td> <div class="brown-bg-color cal-head-text"><?=$day_num;?></div> <?php } } ?> </td> <?php $day_num++; $day_count++; if ($day_count > 7){ ?> </tr><tr> <?php $day_count = 1; } } while ( $day_count >1 && $day_count <=7 ) { ?> <td> </td> <?php $day_count++; } ?> </tr></table> <?php if(isset($_GET['day'])){ $sql = "select * from calTbl where calDate ='" . $month . '/' . $_GET['day'] . '/' . $year . "'"; $result = mysql_query($sql); echo '<table class="data-table-class">'; echo '<th>Event Name</th><th>Event Desc</th>'; while($row = mysql_fetch_array($result)){ echo '<tr><td>'. $row['calName'] . '</td><td>' . $row['calDesc'] . '</td></tr>'; } echo '</table>'; } ?> <div class="myClear"></div> <?php ob_flush(); ?> </p> Can anyone help me out? This is the last part and I am good to go! Thanks! I'm trying to convert the following time stamp: 12:03PM to military time 13:03. I'm using the following code, but it's just outputing 12:03: $sampledate=("2010-11-08, 12:03PM CST"); $xplodeDateStamp = explode(", ", $sampledate); $xplodeDate = $xplodeDateStamp[0]; $xplodeTime = $xplodeDateStamp[1]; echo "Date: " . $xplodeDate . "<br>"; echo "Time: " . $xplodeTime . "<br>"; echo "Military Time: " . date("H:i",strtotime("$xplodeTime")); Greetings experts, Please forgive me for this cheap question. I have got a calendar of events and displays events for 7 departments. For each department, we would like the calendar to display events specific to that department. The way I am thinking about doing this is to grab the department from the url and compare it with the department on the db for which events is inserted into the db with. If there is a match, then display the events for that department. Something like: $tquery = "select * from ".$EVENTS_TB." where ".$EVENTS_TB.".month='".$smmonth."' and ".$EVENTS_TB.".year='".$smyear."' and ".$EVENTS_TB.".deptid='deptFromQueryString' " ; The problem that I have is that I don't in php, how to capture the querystring from url. For instance, assume this is the url: http://www.domain.com/departName. DeparmentName represents the department value. How do I capture the query above? Thanks so much.
I've inherited some PHP code that is trying to save a querystring to a variable: $from_url = ''; if ((isset($_GET['from'])) && ($_GET['from'] != '')) { $from_url = $_GET['from']; }
I have the current rule in my htaccess RewriteRule ^catalogue/([a-z0-9-]+)/([a-z0-9-]+).php$ catalogue/item.php?id1=$1&id2=$2 [L] however whenever i type in the browser /catalogue/computers/cases.php and then change the category to a category not in my database it still shows the item.php page but without any data - blank page. How do you redirect this to a 404 or do I just write a script that if no records are found in the database redirect to the main catalogue page? Anyone know how i can remove a querystring from url. Example URL: http://www.mysite.com/?id=1 I am writing a script that needs to read in the ID from the URL. But once have got the information i would like to remove it from the URL and just display http://www.mysite.com but still be able to use the ID to query my database. Any ideas??? I am working with a fellow who runs an eCommerce shop. The transaction resolution comes in on a querystring.
I do not yet know what web server software is being used, nor if any security appliance/software is installed.
One of the values in the querystring starts with the @ character.
We know the web server gets this as there entries in the web server's access log that shows thing value is present.
It is not available in PHP's $_GET array.
We are trying to get an idea of where this value, and it's key, is getting discarded.
Is there a known problem with (actual server software being used not yet known) web server software discarding a key/value if the value has the @ character in the querystring?
Hi, how to let php read the url in folder form instead of querystring? e.g. www.example.com/index.php?post=123 www.example.com/post/123/ both is actually directed to the same page - index.php, but how to make it read like a folder when the physical path doesn't really exist? Hi: I am trying to pass/request a Variable/QueryString from one page to another, but it isn't working. Seems like it would be simple, so maybe I am overlooking the obvious. I have the 1st page: Code: [Select] <a href="NewCity.php?abbr_state=<?php echo $abbr_state ?>">Insert New City</a> Writes the URL properly - CityList.php?abbr_state=CT The 2nd page: Code: [Select] <?php $abbr_state = $_REQUEST['abbr_state']; ?> <form> State: <input type="text" name="abbr_state" value="<?php echo $abbr_state; ?>" readonly=""/><br /> </form> But it does not get the variable/QueryString for "CT" and add it to the form field (it's not the "readonly" causing it). Why? What did I miss? Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack Hello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. Alright, I have a Datetime field in my database which I'm trying to store information in. Here is my code to get my Datetime, however it's returning to me the wrong date. It's returning: 1969-12-31 19:00:00 $mysqldate = date( 'Y-m-d H:i:s', $phpdate ); $phpdate = strtotime( $mysqldate ); echo $mysqldate; Is there something wrong with it? I have tried a large number of "solutions" to this but everytime I use them I see 0000-00-00 in my date field instead of the date even though I echoed and can see that the date looks correct. Here's where I'm at: I have a drop down for the month (1-12) and date fields (1-31) as well as a text input field for the year. Using the POST array, I have combined them into the xxxx-xx-xx format that I am using in my field as a date field in mysql. <code> $date_value =$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; echo $date_value; </code> This outputs 2012-5-7 in my test echo but 0000-00-00 in the database. I have tried unsuccessfully to use in a numberof suggested versions of: strtotime() mktime Any help would be extremely appreciated. I am aware that I need to validate this data and insure that it is a valid date. That I'm okay with. I would like some help on getting it into the database. Hi, I have a job listing website which displays the closing date of applications using: $expired_date (This displays a date such as 31st December 2019) I am trying to show a countdown/number of days left until the closing date. I have put this together, but I can't get it to show the number of days. <?php $expired_date = get_post_meta( $post->ID, '_job_expires', true ); $hide_expiration = get_post_meta( $post->ID, '_hide_expiration', true ); if(empty($hide_expiration )) { if(!empty($expired_date)) { ?> <span><?php echo date_i18n( get_option( 'date_format' ), strtotime( get_post_meta( $post->ID, '_job_expires', true ) ) ) ?></span> <?php $datetime1 = new DateTime($expired_date); $datetime2 = date('d'); $interval = $datetime1->diff($datetime2); echo $interval->d; ?> <?php } } ?> Can anyone help me with what I have wrong? Many thanks |