PHP - Database Item Expire After Certain Amount Of Time
did some searching on the internet and didnt find much.
i have created an online classifieds website and want all created listings to expire and delete after a certain amount of days. honestly i have no idea where to start with this implementation. cookies were the only thing that even crossed my mind... any ideas? btw each listing is stored in a table called ob_listings Similar Tutorialsi make a site and give a option to uploaded a file but i want to give time period so that there is time limit for downloading after that time interval file is not able to download, so please help me how can i do that. thanks how can i set a session to expire after a set amount of time, say 1 hour. i'm using the following code to create my session, but i dont know what i need to add to make it expire $_SESSION['pageviewsid'.$id] = $new; $new is the result from a calculation and $id is the page id from the URL using $_GET Assume this project is to create an online lottery system. Is there a way to limit the user entering the numbers after a certain time? E.g. The Draw will be at 9.00PM 05 November 2010 - Submitting the numbers will expire after 8.00PM 05 November 2010. (so any user tries to submit numbers after 8.00PM 05 Nov 2010 will not be entered in to the MySQL db). Any help is highly appreciated. Let's say I am buying a share for $10. If I sell the share on the same day BEFORE 3:30PM, it will be sold for $10, but if I keep the share past 3:30PM, I want the code to automatically add $1 (Taxes and such) once in the the price of the share in database, after that no matter how many days pass by, the price will remain the same.
I've thought about CRON jobs, but I have no idea how to make/use them or set them up.
Any direction or help is appreciated.
Hi guys, Im a newb here, so bear with me! Still learning the ropes. I want to delete all files from my server that are 6 hours old since being uploaded to the site. I believe i need a cron job? I currently have this script in its framework... Code: [Select] <?php //time interval for deletion to occur... $x = 30; //timestamp $current_time = time(); //the file you wish to delete $file_name = 'file.txt'; //timestamp $file_creation_time = filemtime($filename); //extract difference $difference = $current_time - $file_creation_time; //if difference = $x...then delete file if ($difference == $x) { unlink($file_name); } Would that work automatically or would it need a cron to run it? And how could i test it, that bit worries me. Many thanks. I have a PHP if() instruction. Within this if() instruction is a curl string which talks to a payment gateway. This gateway went down today, and caused my payment processing pages to hang. I am wondering if there is a way to make PHP abort a processing a instruction after a certain amount of time it runs? Hi, I'm not necessarily looking for code examples for my problem, (they are welcome but its not my explicit goal). I'm looking more for advice on how to go about tackling the problem i have. what i already have Currently i have a search getting results from a MySQL database. The results are ordered by one field that signifies their importance. Many of these results have the same value in this one column, and i have a switch statement to distinguish different content/styles for the different values. (there are just over 10 different bands) So the most important results are shown first and with a different style to the ones below it. (some bands have the same styling) what i need I would like to be able to randomize the results but only randomize the results within their specified bands. e.g. lets say theres 100 results in band A and 100 in band B. I still want everything in band A to be listed above band B, but i would like to randomly change the order of the results in band A and band B, (in this case once a week). I need to save the order of this randomization (client/server side?) for a week, then run the script again to set a new order. Now I would still class myself as an amateur php'er so at this stage i dont even know how i would go about separating the bands and randomizing their results independantly, let alone causing this functionality to run only once a week. So can anyone suggest a way i might go about this? I'm pretty stuck right now. Cheers Hi, I am new to PHP world!! I am just trying to find a way to disable a button after its been clicked for lets say 5 minutes. I have searched google and haven't found what I am looking for. I just dont want the users to be able to refresh the page and the button becomes enabled again. any code examples with explanation or a simple tutorial will be much appreciated. Thanks I have am working on a shopping cart, for coupong buying. Here it only allows me to add one Item or One deal ata time into shopping cart. How can I change this code to accept more than one deal at a time before checking out. Code: [Select] { // add to cart /* $cart = unserialize(JFactory::getSession()->get('cart')); if (empty($cart)) $cart = new Cart(); */ // We only allow 1 item per cart from now one... $cart = new Cart(); $cart->addItem($deal); JFactory::getSession()->set('cart', serialize($cart)); $dealName = $deal->name; $buy4friend = $_GET['buy4friend']; $cartItemCount = $cart->getItem($dealId)->getCount(); if($buy4friend == 1) { $msg = $dealName . " :::<b> ". JText::_("DEAL_ADD_TO_CART_MESUN"); $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=viewCart&buy4friend=1", false); JFactory::getApplication()->redirect($link, $msg); }else{ $msg = $dealName . " ". JText::_( "DEAL_ADD_TO_CART"); $link = JRoute::_("index.php?option=com_enmasse&controller=shopping&task=viewCart&buy4friend=0", false); JFactory::getApplication()->redirect($link, $msg); } Heres what i got... function printLB1 (){ $result = mysql_query("SELECT * FROM leaderboards ORDER BY CollegeFootballPoints DESC"); while ($row = mysql_fetch_object($result)) { $leaderboard[] = $row->Username; $leaderboardPoints[] = $row->CollegeFootballPoints; } $num = mysql_num_rows($reault); //I know from here to ................... needs to be in a var or echo or something. <tr> <td>1.</td> //This will auto increment too like i++ but i cna do that myself! <td>echo $leaderboard;</td> <td>echo $leaderboardPoints;</td> </tr> //Here......................................................... } I need to pull a table row per user. But i want to somehow do it once in a function and then ill echo the function into a table after the php stuff is done. Like i want to pull every a table row per user in the function. then display the function below that way i don't have to write a whole extra query and table row per person. If you understand please help if not please let me know where i can explain more. Thanks Hi, I need to write some code for this but unsure where to start. Basically i have a database of say 10 rows. I need to be able to input a number and some sort of fair algorithm will choose one of the rows. The number will be from 6 to 10 numbers long, and will need to pick the same result each time based on that number. Its for a lotto game Hi All, First time posting here. I've googled the problem, but can't seem to find a response that's the same. All I want to do is have a list of id numbers and for each id number in the array, submit a MySQL query to retrieve information relating to the id number. When I execute the code below however, I end up with only the last item in the array being printed in the echo statement. Any clues? Thanks, Code: [Select] // get array of ids $ids = getIDs($ids); // loop through input list foreach ($ids as &$id) { getVarDetails($id); } function getVarDetails($local) { $con = mysql_connect('localhost:3306', 'root', '********'); if (!$con) { die('Could not connect: ' . mysql_error()); } // set database as Ensembl mysql_select_db("Ensembl", $con); $result = mysql_query("SELECT * FROM variations WHERE name = '$local' LIMIT 1"); $row = mysql_fetch_array($result) while($row = mysql_fetch_array($result)) { echo $row['name'] . " " . $row['id']; echo "<br />"; } // close connection mysql_close($con); } i have 8 division (div), i want to display 4 rows in 4 division and the remain 4 rows in the next 4 division here is my code structure for carousel
<div class="nyie-outer"> second row third row
fourth row fifth row sixth row seven throw eighth row
</div><!--/.second four rows here-->
sql code
CREATE TABLE product( php code
<?php how can i echo that result in those rows
I have a script that seems to work well to insert a bookmark into a users database when he/she is logged into the system but I am having a hard time figuring out how I would go about making a work-a-round for having an item selected before being logged in, and inserted after they have logged in or registered. For example, I would like a user to be able to select an Item to add to bookmark whether that user is logged in/registered or not and if they are not, they would be greeted with a login/registration form and after successful login the add bookmark script would be initiated on the item previously selected. What I've got this far: Simple form to add bookmark: <form name="bm_table" action="add_bms.php" method="post"> <input type="text" name="new_url" value="http://" /> <input type="submit" value="Add Bookmark"/> </form> Then I have the add bookmark script: BEGIN php $new_url = $_POST['new_url']; try { check_valid_user(); //cannot get past this part since it ends the script....code below if (!filled_out($_POST)) { throw new Exception('Form not completely filled out.'); } // check URL format if (strstr($new_url, 'http://') === false) { $new_url = 'http://'.$new_url; } // check URL is valid if (!(@fopen($new_url, 'r'))) { throw new Exception('Not a valid URL.'); } // try to add bm add_bm($new_url); echo 'Bookmark added.'; // get the bookmarks this user has saved if ($url_array = get_user_urls($_SESSION['valid_user'])) { display_user_urls($url_array); } } catch (Exception $e) { echo $e->getMessage(); } END php Checking valid user - the portion I cannot get past in the above script: function check_valid_user() { // see if somebody is logged in and notify them if not if (isset($_SESSION['valid_user'])) { echo "Logged in as ".$_SESSION['valid_user'].".<br />"; } else { // they are not logged in do_html_heading('Problem:'); echo 'You are not logged in.<br />'; do_html_url('login.php', 'Login'); do_html_footer(); exit; } } How would I go about modifying the script so that a user could fill in the form (later it would be a link...obviously they probably wouldn't be filling in a form that is log-in specific - but same concept I think) Thanks in advance for the help! tec4 Hi there, I think this is a big question but I'd appretiate any help you can provide!! I have a list of items and subitems in a table that looks like this: id parent_id title 1 0 House Chores 2 1 Take Out Trash 3 1 Clean Room 4 0 Grocery List 5 4 Eggs 6 4 Produce 7 6 Lettuce 8 6 Tomato 9 4 Milk I want to display it like this: (+) House Chores: > Take Out Trash > Clean Room (+) Grocery List: > Eggs (+) Produce > Letutce > Tomato > Milk So basically each entry in the table has an unique id and also a parent id if it's nested inside another item. I "sort of" got it figured out in one way, but it doesnt really allow for nested subgroups. I'd like to know how would y'all PHP freaks to this Also taking suggestions for the javascript code to expand/collapse the tree !! Thank you! Anyone can help me how to get the time when log.in and the time when log.out then it will store in database... tnx when user login to his account, I want to expire session after 5 minutes I am trying to find a way of deleting entries from a database after a certain time, and also when there is another field in the database set to 0. i have got so far with the code (will delete when other field is at 0) but nothing happens when i try to add in the time. my code im trying to use is below mysql_query("DELETE FROM temp_users WHERE book_stage='0' and WHERE time() > [creation+60]"); creation being the name of the field in the database that holds the unix time stamp of when the entry was created. i need the entry to be deleted one hour after it was created if the book_stage hasnt been changed to 1 during this hour. many thanks, gavin Hi All, if we read performance rules given by yahoo they suggest to add expire header for JS and css files. my question is how to add expire header for different JS and CSS files. reference URL :- http://developer.yahoo.com/performance/rules.html#expires Assume I have a php page that have 5 js and 2 css it may be anywhere in html document for eg <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <script language="javascript" type="text/javascript" src="test.js"> </script> <title>Untitled Document</title> </head> <body> <script language="javascript" type="text/javascript" src="test2.js"> </script> SOME HTNl CONTENT <script language="javascript" type="text/javascript" src="test3.js"> </script> <script language="javascript" type="text/javascript" src="test4.js"> </script> <img src="1.gif"> </body> </html> My question is how I will add expire header in every JS, CSS and images. I have a restriction:- I cannot use ob_start() for the output buffering. |