Jump to content

Search the Community

Showing results for tags 'date'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello, I have csv filename with date. Everyday i have same csv file with respective date. I need to read filename (everyday date changes in filename) and do operation. For example, I have file "cells_20140106_165532.csv". I did like this to read it in general: $filename = "cells_".date('Ymd_hmi').".csv"; $file_contents = file_get_contents($filename); $importcsvsql = ""; It is taking current date instead of filename's date. It is generating empty file "cells_20140114_110109.csv" Thanks in advanced.
  2. Hello, I have one "tar.Z" file. Objective is to unzip it by shell script and check the date. File archive: filename_20140103_1540.tar.Z #!/bin/bash cd $REP_DATAS/path u=$(date +%u) if [ ${u} -eq 1 ] ; then dateQ=`date --date='-3 day' +'%Y%m%d_%H%m'` else dateQ=`date --date='-1 day' +'%Y%m%d_%H%m'` fi tar xvf filename_"dateQ".tar.Z THANKS IN ADVANCED.
  3. My php script always returns different times. Example: The current time is 4:33pm and the script returns 11:33am. Then sometimes it is correct, and then randomly switches to something like 7:33pm when it should be 5:33pm. This is my code $time = new DateTime(); $time->setTimezone(new DateTimeZone('America/Chicago')); $time = $time->format('g:i A'); echo $time; I don't know if makes any difference, but I'm renting a server from Go Daddy for my website and it is running Linux. How would I fix this problem? Edit: I'm also having a problem with the "time()" function giving results that are hours off.
  4. Hi Guys. Im just trying to find a list of people with birthdays coming up in the next 14 days from a table in my db. I'm storing birthday as a unix timestamp. Currently I have one birthday coming up on the 10/12/1984 or unix time would be 471484800. My query is returning 0 as the number of birthdays when it should say 1. mysql_select_db($database_dbconnect, $dbconnect);$query_Birth = "SELECT StaffDOB FROM Staff WHERE StaffDOB BETWEEN UNIX_TIMESTAMP(CURDATE()) AND UNIX_TIMESTAMP(ADDDATE(CURDATE(), INTERVAL 14 DAY))";$Birth = mysql_query($query_Birth, $dbconnect);$totalRows_Birth = mysql_num_rows($Birth); echo $totalRows_Birth;
  5. i have the below given time interval options in a dropdown (those are strings) <select name="CSSAtapsClient[client_time_window][0]" id="client_time_window_0"> <option value="5702">7am - 10am</option> <option value="5703">10am - 1pm</option> <option value="5704">12pm - 3pm</option> <option value="5705">3pm - 6pm</option> <option value="5706">6pm - 9pm</option> <option value="5707">7pm - 10pm</option> <option value="5708">9pm - 12am</option> <option value="5709">12am - 7am</option> </select> I need to convert these intervals for a specific GMT time zone. for example lets say its in GMT +8 and i need to convert it to GMT +10 and it can be done by adding 2 hours. so if the given time interval is, 7am - 10am (GMT + it should come as 9am - 12pm (GMT +10) What is the best way to convert this kind of a time interval ? The issue i am seeing here is its a string (time interval). Appreciate an early reply. EDIT 1 I am converting to only Australian states so there is no chance of getting a day as difference when converting. pls check this link http://www.timebie.com/tz/australiatimezone.php
  6. Hello. This is my PHP/MySQL code <?php $result = mysqli_query($con,"SELECT * FROM tutorials"); ?><table border="1"> <?php while($row1 = mysqli_fetch_array($result)) { echo '<tr>'; echo '<td><p>'; echo $row1['Name'] . "</p></td><td>" . $row1['ShortDescription']; echo '</p></td>'; echo '</tr>'; } ?></table> When it displays, it shows the newest columns in the table last. How do I reverse that.
  7. Hi all ! I need some help. I'm not a programer but I would like to solve problem with my website by myself. After upgrading PHP on server where is my web page ( www.osmrtnica.net ), i'm getting a lot of errors in my CMS. I hope that someone will have a few minutes to give a look. I have bolded text in code at line 380. And i know that is a lot of text, but what can i do. Thanks in advance. here are the errors: <br /><b>Warning</b>: main() [<a href='function.main'>function.main</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Notice</b>: Use of undefined constant date - assumed 'date' in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: strtotime() [<a href='function.strtotime'>function.strtotime</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: strtotime() [<a href='function.strtotime'>function.strtotime</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: date() [<a href='function.date'>function.date</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: date() expects parameter 2 to be long, string given in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /> And here is a part of code where error ocurs: <div class="h3" style="height:1px;"> </div> <div style="width:450px; float:left; "> <label for="odobreno">odobreno:</label> <input type="checkbox" class="chk" name="odobreno" id="odobreno" value="1"<?php if ($row['odobreno'] == 't') { ?> checked="checked"<?php } ?> /> <label for="datum">datum:</label> <input type="text" name="datum" id="datum" class="tekst srednji" value="<?php if ($row['datum'] != '') print date('d.m.Y', date.strtotime($row['datum'])); else print date('d.m.Y'); ?>" /> <script type="text/javascript"> <!-- $(document).ready(function(){ $('#datum').datepicker({ mandatory: true, navigationAsDateFormat: true, prevText: '<M', nextText: 'M>', changeMonth: false, monthNames: ['siječanj ','veljača ','ožujak ','travanj ','svibanj ','lipanj ', 'srpanj ','kolovoz ','rujan ', 'listopad ','studeni ','prosinac '], monthNamesShort: ['sij','velj','ožu','tra','svi','lip','srp','kol','ruj','lis','stu','pro'], changeYear: false, weekHeader: '', showWeeks: true, dayNames: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'], dayNamesShort: ['ned', 'pon', 'uto', 'srij', 'čet', 'pet', 'sub'], dayNamesMin: ['N', 'P', 'U', 'S','Č', 'P', 'S'], showOtherMonths: true, numberOfMonths: 1, defaultDate: Date(<?= date('Y, m, d', strtotime($row['datum'])); ?>), // default date - Date(yyyy, mm - 1, dd), dateFormat: 'dd.mm.yy', showWeeks: true, firstDay: 1, changeFirstDay: false, closeText: 'X', prevText: '<', nextText: '>', currentText: '' }); }); //--> </script>
  8. I have a php program which accepts the input of the YYYY-MM-DD as the date format and stores it to the database. As soon as the user enters the date with YYYY-MM-DD format (e.g 1990-06-22) how can I convert the 06 (or the MM part) to June as in the 6th month of the year?
  9. I am fairly new to .php and am having some trouble trying to calculate a date. I have an .html form that uses .php to send the data from the form in an email. On the form I have a jquery calendar where the user can select the date a service is needed. The user also enteres the time the service is needed as 24 hour time. I am able to pass the data and everything works fine. Originally we didn't need the date/time to be anymore than integers. So this is how the date and time are passed in the .html: <script> $(function() { $( "#datepicker" ).datepicker(); }); </script> <input name="datepicker" type="text" id="datepicker" size="10" maxlength="10" /> <input name="req_time" type="text" size="4" maxlength="4" /> the variable $datepicker passes the date to the .php and gets entered into the email as "Date Needed" formatted as mm/dd/yyyy. the variable $req_time" passes the date to the .php and gets entered into the email as "Time Needed" formated as 0000 (integer). However, now I need to check the date and time entered and compare them to the system date. If the entered date and time are less than 72 hours from the system date, I need to force a popup message. I have the popup message working. I just have no clue how to: 1) convert the entered date/time ($datepicker/$req_time) values to a date/time that can be calculated. 2) grab the saystem date/time in a value that can be calculated. 3) determine if the entered date is 72 hours or less from the syatem date. Can this be done in .php and if so, can someone assist me? SpaceChick
  10. Hi all, So i am passing a data from a form, in the format yyyy-mm-dd. I want to convert that to dd/mm/yyyy but for some reason i cant get it to work. Can anybody tell me what im doing wrong? $date = $_GET['date']; $date_uk = $date->format('d/m/Y'); Error is: Fatal error: Call to a member function format() on a non-object Thanks in advance for any help, Matt
  11. I am making a php calendar but struggling to get the query to work. The php calendar is made through a function with 3 variables fed into it. you can find the full calendar http://davidwalsh.name/php-event-calendar Anyway back to my variables. 3 of them.... $month, $year, $events Which are gotten as so.... /* date settings */$month = (int) ($_GET['month'] ? $_GET['month'] : date('m'));$year = (int) ($_GET['year'] ? $_GET['year'] : date('Y')); /* get all events for the given month */$events = array();mysql_select_db($database_dbconnect, $dbconnect);$query = "SELECT title,idcalendar, DATE_FORMAT(event_date,'%Y-%m-%D') AS event_date FROM calendar WHERE event_date LIKE '$year-$month%'";$result = mysql_query($query, $dbconnect) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) {$events[$row['event_date']][] = $row;} Now I have my 3 vars I feed them into my function with the following line <?php echo draw_calendar($month,$year,$events); ?> Now within my function there is the following line to print out the event on any given day /* list the events */if(isset($events[$event_day])) {foreach($events[$event_day] as $event) {$calendar.= '<div class="event">'.$event['title'].'</div>'; }}else {$calendar.= str_repeat('<p> </p>',2);} As you can see if it finds an event it will show it and if it cant it will show 2 empty paragraph tags. I have an event in my database and under the field titled event_date and the event is for 2013-07-16 00:00:00 which is obviously today. If I use MySQL to run the query it pulls back my event quite happy. As soon as I run it in the webpage I get my empty paragraph tags back. Please help
  12. How to change the date format, the default date in mysql is" yyyy-mm-dd", I want to change it to "dd-mm-yy", hoping to get the reply soon....
  13. can just say i am all mixed up about dates and mysql. in a database should i store in an 7/12/13 format or with as a Unix Timestamp (epoch i think). so what is the best way to store dates into a database and convert back to human readable or should i make it human readable in the database If also someone could point me the right direction of a tutorial or book or something that would be good too
  14. Hi, I want to change this code to show time from current just for today. you can see on the webiste there is time from tomorrow but not from morning , but from current time. this is the code. can you please help ? http://www.dublincitycouriers.com/index2.php <label>Pickup Time</label> <select name="pickuptime"> <? $i=date('G', time()); $i++; while($i<18) { $date = gmmktime($i, 0, 0, gmdate("m") , gmdate("j",$selectDate), gmdate("Y")); if($date==$_SESSION['pickuptime']) { echo "<option selected value=\"".$i."\">".gmdate('H:00',$date)."</option>"; } else { echo "<option value=\"".$i."\">".gmdate('H:00',$date)."</option>"; } $i++; } ?>
  15. Hey guys, Does anyone know a simple ,clean way of getting the time between a past date and todays date in seconds? I'm trying to figure out what the Linux Timestamp is about. I know it's the time since 1970 to now, but I don't see how I could use that here or why it's used. Perhaps someone could also give me a clue as to what it's mostly used for. THANKS!
  16. I have a SQL query where I am retrieving information to a table. I would like to only retrieve data from yesterday. I found some PHP code which I´ve formated to look exactly as the Date does in the database (2013-05-30) YYYY-mm-dd but I can´t get it to work. Does someone see what the error might be? <?php $date = new DateTime(); $date->add(DateInterval::createFromDateString('yesterday')); $conn = mysql_connect($dbhost, $dbuser, $dbpassword); if(! $conn ) { die('Could not connect: ' . mysql_error()); } mysql_select_db($dbname, $conn); echo '<STYLE TYPE="text/css">'; echo 'TD{font-family: Arial; font-size: 9pt;}'; echo '</STYLE>'; echo '<table border=1><thead><tr><th>Namn</th><th>Datum</th><th>SE Mail</th><th>SE Backoffice</th><th>DK Mail</th><th>DK Backoffice</th><th>NO Mail</th><th>NO Backoffice</th><th>FI Mail</th><th>FI Backoffice</th></tr></thead><tbody>'; $q = mysql_query("SELECT id, name, Date, SEMail, SEBackoffice, DKMail, DKBackoffice, NOMail, NOBackoffice, FIMail, FIBackoffice FROM maildata WHERE Date = $date->format('Y-m-d')"); while($f = mysql_fetch_array($q)) { echo '<tr><td>'.$f['name'].'</td><td>'.$f['Date'].'</td><td>'.$f['SEMail'].'</td><td>'.$f['SEBackoffice'].'</td><td>'.$f['DKMail'].'</td><td>'.$f['DKBackoffice'].'</td><td>'.$f['NOMail'].'</td><td>'.$f['NOBackoffice'].'</td><td>'.$f['FIMail'].'</td><td>'.$f['FIBackoffice'].'</td></tr>'; } echo '</tbody></table>'; mysql_close($conn); ?>
  17. hi, im a newbie here. im seeking help for my problem. i am also new in php but have some knowledge in sql here's my problem. my boss wants to enable update the baking chamber table once the Estimated End Time reached only. meaning if the end time doesn't meet there will be a pop up on the page that operator cannot finished unless the estimated end time is reached. Please kindly help check my code and see screenshot attached for your reference. Thanks in advanced guys. if($_POST['submit']=="Bake Finished") { $time = strftime('%I:%M %p'); $hours = strftime('%H'); $min = strftime('%M'); $query=mysql_query("SELECT * FROM tbl_baking_chamber"); while($result=mysql_fetch_array($query)) { $recno=$result['RecNo']; if(isset($_POST[$recno])!=NULL) { mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.TotalTime='$TotalTime' where RecNo='".$recno."'"); mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.EndTime='$CurrentDate - $time' where RecNo='".$recno."'"); mysql_query("UPDATE tbl_baking_chamber set tbl_baking_chamber.Status='Finished' where RecNo='".$recno."'"); } } } if($_POST['submit']=="On Baking" || $_POST['submit']=="Bake Finished") { echo "<table class='tbl_Forbaking' cellspacing='1' border='0' width='680'>"; echo "<form action='Applications.php?type=BGABaking' method='post'>"; echo "<tr>"; //echo "<td class='text2' align='center' bgcolor='e3e6e5' height='40'>"."MODEL"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."SERIAL NUMBER"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."DEFINED <br> BAKE TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."BATCH"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."LOCATION"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."START TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."ESTIMATED <br> END TIME"."</td>"; echo "<td class='text2' align='center' bgcolor='e3e6e5'>"."<input type='submit' name='submit' value='Bake Finished' class='btn_Bake'>"."</td>"; $Query = mysql_query("SELECT * FROM tbl_baking_chamber where Status='On Baking'"); $count = mysql_num_rows($Query); $bgcolor="e3e6e5"; while($result = mysql_fetch_array($Query)) { if($bgcolor=='e3e6e5') { $bgcolor='e9ebea'; } else { $bgcolor='e3e6e5'; } echo "<tr>"; //echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Model']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Serial']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['BakingHours']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Batch']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['Chamber']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['StartTime']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>".$result['SEndTime']."</td>"; echo "<td class='text1' align='center' bgcolor='$bgcolor'>"."<input type='checkbox' value='$result[RecNo]' id='$result[RecNo]' name='$result[RecNo]'>"."</td>"; } echo "</form>"; echo "<tr>"; echo "<td>"."<br/>"; echo "<tr>"; echo "<td class='text4'>"."Total QTY.: $count"; echo "</table>"; }
  18. Hi all, Ok so i have a bit of a tricky question. I am using a query to return just time from a datetime variable '_sfm_form_submision_time_' based on a few conditions as follows: if(isset($_GET['mrn'])) { $Search = $_GET['mrn']; $Find_Query1 = mysql_query("SELECT DATE_FORMAT(_sfm_form_submision_time_,'%H:%i') AS time, SBP FROM obs WHERE mrn='$Search' AND DATE(_sfm_form_submision_time_) = $chosendate() order by time ASC"); if(!$Find_Query1) { die(mysql_error()); } while($row = mysql_fetch_assoc($Find_Query1)) { echo '<br/> TIME: '.$row['time']; echo '<br/> SBP: '.$row['SBP']; echo '<br/>'; } $numCount = mysql_num_rows($Find_Query1); if ($numCount < 1) { print("no sbp/time found for that mrn on chosen date"); } However, i want to make a correction to the returned 'time', for daylight saving. In the UK daylight saving time (British Summer Time - BST) starts at 1am on the last Sunday in March (1am GMT), and finishes at 2am BST (ie 1am GMT) on the last Sunday in October. To make things more complex, my server saves datetimes as 4 hours behind GMT (which i cant change), so i also want to correct for this. So, if the date '_sfm_form_submision_time_' was recorded was in daylight saving time I want to add 3 hours to 'time', otherwise i want to add 4 hours to 'time'. Does anyone have any clue how to do this?? Any help anyone can give would be amazing! Thanks Matt
  19. I need help displaying more than 12 months on this project. I can't seem to make this loop work without repeating months of the year. All I really need is to display more than 12 months at a time. echo" "; date_default_timezone_set('America/Los_Angeles'); $dateComponents = getdate(); $month = $dateComponents['mon']; $year = $dateComponents['year']; $max = 0; while($max < 12){ if($month == 13){ $month = 1; $year++; } $thisMonth = date("F", mktime(0, 0, 0, $month, 1, 2012)); echo "#$thisMonth$year "; $month++; $max++; } echo " "; ?>
  20. Table: cquestions -> cqid, cqtext, showdate. I want to update 'showdate' field to tomorrows date.. cqid cqtext showdate 200 q1 2013-05-22 201 q2 0000-00-00 202 q3 0000-00-00 the idea is to display only one question everyday. showdate is compared with the current date and display the first question q1. the starting date only store in db. now i want to update only the next row (q2)'s showdate to tomorrows date. next day wen q2 is displayed q3 will be updated to tomorrows date. today q1 displayed. db is like this. cqid cqtext showdate 200 q1 2013-05-22 201 q2 2013-05-23 202 q3 0000-00-00 tomorrow q2 displayed. then db cqid cqtext showdate 200 q1 2013-05-22 201 q2 2013-05-23 202 q3 2013-05-24 203 q4 0000-00-00 my code: $today=date("Y/m/d"); $tomorrow= date("Y-m-d", strtotime("tomorrow")); echo "<form method='post' id='submit' action='checkresult.php'>"; $sql="SELECT * FROM cquestions where showdate= '$today' limit 1"; $result=mysql_query($sql); while ($row = mysql_fetch_array($result)) { $cqid=mysql_result($result,"cqid"); $update1="update cquestions set showdate='$tomorrow' where showdate='0000-00-00' and cqid!='$cqid' order by cqid limit 1"; mysql_query($update1); echo "<p>" . $row['cqtext'] . "</p>"; $sql2="SELECT * FROM canswers where cqid=".$row['cqid']; $result2=mysql_query($sql2); while($row2=mysql_fetch_assoc($result2)){ echo "<input type='radio' name='".$row['cqid']."' value='".$row2['cqans']."' />".$row2['aatext']; } /*echo "<input type='hidden' name='email' value='email' />";*/ } echo"<input type='submit' id='submit' name='submit' value='Submit Answers' />"; echo "</form>"; ?> this code update the next row, but the problem is its executed every time page loads and update the next row... i want to execute the update query only once for the day. how to do it?
  21. I have a table that is being dynamically generated off of a SQL query. I am trying to convert a date to the American version of the date field (m,d,y), however there is an error in my code. Can someone help me out? Any help is appreciated! Thanks in advance! echo "<td>"date('d-m-Y', strtotime(.$row['submit_date'].));"</td>";
  22. i have a string like this "20 Dec, 2011", is there a way find out which day of the week is this?
  23. Hey guys I am currently updating my site and in all honestly I suck at javascript. My site is located at http://vampire-news.webs.com . At the top my main banner sits in the middle. I am truly considering moving my banner to the left side of the header and adding a quote of the day(or something else useful) to the right side to fill the gap. I used to have a script that did this and it worked perfectly. The issue I cannot think of a way around is a quote every day for 365 days. Can javascript use get date() and use an array of 365 objects to display a different one each day? Any help is appreciated. If I made no sense I apologize.
  24. How do I search a column for a date which is stored as a var? Is this the best way? $result = mysqli_query($link, " SELECT id, col1, col2, datum, col4, col5, col6, col7, col8, col9 FROM table WHERE `datum` = '$datum' " ) OR die(mysqli_error($link)); Thanks in advance.
  25. Ok, so i am trying to compare a date stored as a variable against a row in mysql, this is where i am so far: I need to be able to search the table for: 1) a search keyword 2) a combination of a date, for example (just 2013) or (march-2012) or (7th of june) or (5th of september 2012) or (just the 16th) etc... $result = mysqli_query($link, " SELECT id, auditor, auditee, datum, department, func, proc, audit_type, copy_to, comments FROM audit_data WHERE ( `auditor` LIKE '%$search_field%' OR `auditee` LIKE '%$search_field%' OR `department` LIKE '%$search_field%' OR `func` LIKE '%$search_field%' OR `proc` LIKE '%$search_field%' OR `audit_type` LIKE '%$search_field%') OR (`id` = '$radio_id') OR (datum = '$datum') " ) OR die(mysqli_error($link)); Its only a small table otherwise I would be indexing. The variable and row are both stored in native format (YYYY-MM-DD) (If i put in a keyword into my $search_field it displays all the rows with a match, that works a treat). The above example shows an exact match between the row and var which as it happen doesnt work. I have a calender setup on the input form and search form that will put in any date like this 2013-04-08 or 2013-00-08 etc. Logically this is what i want (unfortunately doesn't work): if day($datum) = "00" {day($datum) = ""} else { day($datum) = day($_REQUEST['date1'] } if month($datum) = "00" {month($datum) = ""} else { month($datum) = month($_REQUEST['date1'] } if year($datum) = "0000" {year($datum) = ""} else { year($datum) = year($_REQUEST['date1'] } // select select * from audit_data where `datum` = if(isset(day($datum))){day($datum)} OR if(isset(month($datum))){month($datum)} OR if(isset(year($datum))){year($datum)} OR OR [search keyword code here] date1 being the calender output... If the above seem odd, or simply wrong, forgive me, im just trying to get the point across as clear as i can. Can anybody give me a head start on how to do this, any advice, links, examples, structure will be greatly appreciated!
×
×
  • 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.