PHP - Move Table Due In 10 Days Time
Hi all.
I have an issue and don't know how to go about it. I have a table that contains user orders. I want to move only orders that will be due in 10 days time to another table. How can I achieve that? thanks Similar TutorialsHello I have a timestamp formated as : "2011-10-20 12:37:21" I need to show days left till this date (disregard the hours, minutes, seconds..), so I'll end up with 'there is "X" days left untill' I really cannot figure you all this date/time stuff, but hopefully this is not to difficult Anyone got a "quick" code for this? <?php query_posts('meta_key=post_views_count&posts_per_page=3&orderby=meta_value_num& order=DESC'); if (have_posts()) : while (have_posts()) : the_post(); ?> <ul class="rpul"> <li> <div class="class="post-thumb wp-post-image" style=' '> <?php if ( has_post_thumbnail() ) : ?> <?php the_post_thumbnail('thumbnail') ?> <?php endif ?> </div><div class='cat-post-text'> <h1> <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
Hello All, Iam completely new (3days old) to sql, php, html, so could do with a little help. Ok so I just found out about this wonderfull world and thought i would give it a try and I like it. But as I have no real idea of what Iam doing Iam finding it abit tricky to change some of the code I found at. http://www.phpfreaks.com/tutorial/simple-sql-search By the way thanks for this. So far I have setup a wamp server and got it all working fine and tweeked the above details in the url. This works great (well chuffed). But I could do with changing two things for now. 1). I could do with beeing able to search multiple things in the one text box for example. If I inputed "hello world" or "hel wor" it would search through the 19,000 lines in my database and find all instances of "hello" and "world" or "hel" "wor" in the same line's, it dosent matter what column they are in and output those lines. The code has the option to search all feilds "matchall" but not multiple words or parts of words.(hope that made sense I dont know all the terminology) It could be like using wild cards I suppose??. Is this possible or would I need multiple search boxes and if so how would I do that? 2). I would like the results to be returned in a table with headings for each column. If any one can help this would be great and thanks in advance for checking the long post out. Nick. Sorry if this is out there already but not to sure what I need to search for!??!?!? Ill include what Iam using so far. <?php $dbHost = 'localhost'; // localhost will be used in most cases // set these to your mysql database username and password. $dbUser = 'root'; $dbPass = ''; $dbDatabase = 'Stk_search'; // the database you put the table into. $con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error()); mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error()); // Set up our error check and result check array $error = array(); $results = array(); // First check if a form was submitted. // Since this is a search we will use $_GET if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. if (strlen($searchTerms) < 3) { $error[] = "Search terms must be longer than 3 characters."; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } // If there are no errors, lets get the search going. if (count($error) < 1) { $searchSQL = "SELECT id, Stock_Code, SV_Part_Number, SV_Description, SV_Search_Key FROM stkdb1 WHERE "; // grab the search types. $types = array(); $types[] = isset($_GET['Stock_Code'])?"`Stock_Code` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['SV_Part_Number'])?"`SV_Part_Number` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['SV_Description'])?"`SV_Description` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['SV_Search_Key'])?"`SV_Search_Key` LIKE '%{$searchTermDB}%'":''; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) if (count($types) < 1) $types[] = "`Stock_Code` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked $andOr = isset($_GET['matchall'])?'AND':'OR'; $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `Stock_Code`"; // order by title. $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$i}: {$row['Stock_Code']}<br />{$row['SV_Part_Number']}<br />{$row['SV_Description']}<br />{$row['SV_Search_Key']}<br /><br />"; $i++; } } } } function removeEmpty($var) { return (!empty($var)); } ?> <html> <title>My Simple Search Form</title> <style type="text/css"> #error { color: red; } </style> <body> <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?> <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> Search For: <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /><br /> Search In:<br /> Stock_Code: <input type="checkbox" name="Stock_Code" value="on" <?php echo isset($_GET['Stock_Code'])?"checked":''; ?> /> | SV_Part_Number: <input type="checkbox" name="SV_Part_Number" value="on" <?php echo isset($_GET['SV_Part_Number'])?"checked":''; ?> /> | SV_Description: <input type="checkbox" name="SV_Description" value="on" <?php echo isset($_GET['SV_Description'])?"checked":''; ?> /> | SV_Search_Key: <input type="checkbox" name="SV_Search_Key" value="on" <?php echo isset($_GET['SV_Search_Key'])?"checked":''; ?> /><br /> Match All Selected Fields? <input type="checkbox" name="matchall" value="on" <?php echo isset($_GET['matchall'])?"checked":''; ?><br /><br /> <input type="submit" name="submit" value="Search!" /> </form> <?php echo (count($results) > 0)?"Your search term: {$searchTerms} returned:<br /><br />" . implode("", $results):""; ?> </body> </html> Hello, I am trying to display rainfall totals for the year so far in a table with months going across and days going down. Like so: -- Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1 2 3 4 5 6 7 8 etc And then have the rainfall totals for each day in the table, I am quite experienced with PHP however I cant work out how I would do this The data is stored in a mysql table called "wx_daily", and the rainfall column is called" RainTotal". The dates are stored in the "Date" column in mysql Date format. Im using the following mysql query: SELECT * FROM wx_daily WHERE YEAR(Date) = '2011' ORDER BY Date Asc Thanks, Mark Hi Is it possible to make a row(with number) increase every time the same value is added to the table? Example: I enter "test" into a table and it gets the following data: id=1 name=test count=1 And the next time I enter "test" into the table it becomes id=1 name=test count=2 instead of id=1 name=test count=1 id=2 name=test count=1 I want to create a form where users can suggest stuff and I want to see what is the most popular ect. Thanks in advance I am in need of suggestions on how too achive this: I have a surf exchange and whenever a member has viewv a site, it ads this members Id and time to a table called vtp_tracking. I have now created a team script, so I can count the total of surf for members within this team from the vtp_table. What I am in need of is this: I would like to add a bonus for the teams, so my idea was this: every hour run a cronjob to get the results for the last hour by team id lik so: Code: [Select] WHERE vtp_members.team_id="teamid" AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date>date_sub(NOW(),interval 60 minute I believe the above code will work fine and get me the results for team members for the last hour. Problem: how can I get this result, multiple it with the value from another field and divide by 100 and add this to a third field? eg: (result from above * value from other field / 100) then add to a third field. Anyone willing to try and answer this one? Hi, I've making a script that's almost a todo list, and i want to have 3 colors to the posts. Post under 7 days old should be green, and thoose older then 7 days yellow and over 14 days should be red. How could i do that? Every post i timestamp when stored in my MYSQL table. Here is my code: Code: [Select] <?php $servername='localhost'; $dbusername='root'; $dbpassword=''; $dbname='store'; connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } $result = mysql_query("SELECT * FROM henvendelser ORDER by id desc ") or die(mysql_error()); echo "<table cellspacing='12px' cellpaddomg='5px' align='center'>"; echo "<tr> <th>ID</th> <th> Opprettet </th> <th>Navn</th> <th>Telefon</th> <th>Emne</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr> <td>"; echo $row['id']; echo "</td> <td>"; echo date("d.m.y", strtotime($row["date"])); echo "</td> <td>"; echo "<a href=\"detaljer.php?view=$row[id]\">$row[Navn]</a>"; echo "</td> <td>"; echo $row['Telefon']; echo "</td> <td>"; echo $row['Emne']; echo "</td> </tr>"; } echo "</table>"; ?> I'm trying to figure out if today's current date and time falls between Mon & Fri, but so far, I can't get it to work. Can anybody look at my code and see what I'm doing wrong? Code: [Select] <?php $day_start = date('D h:i a', strtotime("Mon 05:30")); $day_end = date('D h:i a', strtotime("Fri 10:00")); $day_current = date('D h:i a', strtotime("+1 hours")); if (($day_current > $day_start) && ($day_current < $day_end)) { echo "yup"; } else { echo "nope"; } ?> Thanks in advance Hi there, for every case we have "gooo" as commen in all how this could be one code using anything like elseif or switch whatever... if($refere && (stripos($r, $refere) === false)){ echo "x1" }else{ echo"goooo" } And if($limited && ($line[hits] >= $limited)){ echo "x2" }else{ echo"goooo" } And if($pword && (isset($_POST['password']) && $_POST['password'] == $pword) ){ echo"goooo" }else{ echo"x3" } And if ($line[capt] == 1 && ($_SESSION["security_code"]) ){ echo"goooo" }else{ echo"x4" } thanks in advance Hi, I have db table that records the days (Sunday, Monday...) when the employee login to the system. Say that the employee logged in on Monday then Logged in on Wednesday so this means he was absent on Tuesday. I calculated the number of days to get the answer 2 (between Wednesday and Monday before logging in on Wednesday) how to get the name of the missing day "Tuesday"? code: $curdate = date("Y-m-d"); $currday = date('l'); $lastdate = $row['indate']; $lastdayin = $row['lastdayin']; if ($lastdate !=Null) { $misseddates = strtotime($curdate) - strtotime($lastdate); $misseddates = $misseddates / 86400; echo $misseddates; $misseddays = strtotime($lastdayin) - strtotime($currday); $misseddays = $misseddays / 86400; echo $misseddays; } I tried to get the name of day in the last step but it only calculates 5 in numbers how to get the name. I want the answer to be "Tuesday" as of the example. Thanks. Hello. I want to generate the initial of the day of all the days of a chosen month. Meaning, if I choose this month it will give me: TFSSMTWTFSSMTWTFSSMTWTFSSMTWTF Is that clear? Can anybody help me? thanks! When I try to add 30 days: Code: [Select] $date = date("Y-m-d"); $date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days"); echo $date; and I echo date I get 1330664400 How do I get it to echo out 3/1/2012? I know the answer lies in the strtotime but I can't figure it out. I know it's a simple problem for most of you... I have a SQL row that has a date field: ex: 2010-11-01. When a car is sold there either is a 30 day warranty, a 60 day warranty, or 0 day warranty. What I'm trying to do is display when the vehicles warranty expires, based on the date it was sold, or when did it expire based on the same sold date pulled from the database. Example using last months date: 2010-10-01 60 day: "Expires 11-30-10" 30 day: "Expired 11-01-10" I can not seem to use the date function properly... Any help would be greatly appreciated. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=320501.0 Hello, I am trying to put together a mysql query that will return the number of visitors for four days ago, what i am trying to do is plot the last seven days visitors on a graph in the format of day seven, day six, etc and need to find away to get a count for each of those days. At the moment i am thinking about running various queries with each returning the results for a specific day. The code below is supposed to get the count of visitors four days ago. Not between now and four days ago but just for the 24 hour period which covers day 4. The current code just returns a value of 0. Any help would be appreciated. Code: [Select] $result = mysql_query("SELECT ip FROM ip_stats WHERE date= date_sub(NOW(), interval 4 DAY)"); $num_rows = mysql_num_rows($result); echo "$num_rows"; Hey there, Thanks for taking the time to read my thread. My issue is if I'm given a time stamp in PHP how could I calculate the number of days until that time stamp?. Thanks for your time. Hi I am trying to add a field to a database that is 4 days from the date the record is added, but it is not adding a value Code: [Select] $end_date=strtotime("+ 4 days"); $add_vehicle_sql=mysql_query("INSERT INTO `tbl_auction_lot`(`cust_id`,`reserve`,`make`,`model`,`spec`,`fuel`,`doors`,`mot_date`,`fns`,`fos`,`rns`,`ros`,`condition`,`reg_no`,`service_history`,`sale_type`,`status`,`keepers`,`gearbox`,`emissions`,`colour`,`date_first_reg`,`date_manufacture`,`bhp`,`engine_size`,`end_date`) VALUES ('$seller_id','$reserve','$make','$model','$body_style','$fuel_type','$no_of_doors','$mot','$fns','$fos','$rns','$ros','$vehicle_condition','$vrm','$service_history','auction','$status','$prev_keepers','$gearbox','$emissions','$colour','$date_reg','$date_man','$bhp','$engine_size','$end_date')") or die(mysql_error()); What am I doing wrong and what is there a better way to achieve the desired result. Hello all, The exact thing that i need is to calculate how much days there is in between two dates. The only problem is that every thing that i found dont care about leap year Anyone have a function to do that? Hi, I need to calculate absent percentage but not sure how. working days from Sunday to Thursday every week so 5 working days a week. i will calculate the absent days from joining date until current date. Example if joining date is 24-3-2020 and today's date is 7-4-2020 i should get the number of absent days to 11 days since both Friday and Saturday are excluded. How to do that? here is what I have: $workingdays = $curdate - $joindate; $workingdays = $workingdays - $absent = ($counter / $workingdays) * 100; the second line i missing the number of days for (Fridays and Saturdays) that should be excluded from calculations. The third line i did calculate the actual working days ($counter) for the employee so then i can get percentage of absent days. How to exclude the weekend days from calculations? Edited April 1, 2020 by ramiwahdanmistake in dates please could some one help me i need to limit the query by timestamp for the last 7 days here is my code on the php side Code: [Select] <?php $db = @mysql_connect("localhost", "8conv", "*****") or die("Connection Error: " . mysql_error()); mysql_select_db("tempmonitor") or die("Error connecting to db."); $sql = "SELECT *, UNIX_TIMESTAMP(datetime) AS datetime FROM 8conv"; $result = mysql_query($sql); $data = array(); while ($row = mysql_fetch_array($result)) { $temp1[] = array($row['datetime'] * 1000, (int)$row['temp1']);; } $temp1 = json_encode($temp1); |