Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. This basically boils down to the design of your input form. There will no doubt be a mix of human interpretation of the information given by restauranteurs and coding logic. How much of each will be up to you. However you do it, you need to end up with something like +---------------+------+----------+------------+ | restaurant_id | day | open | close | +---------------+------+----------+------------+ | | | | | Mon closed all day (no record) | 1 | 2 | 11:00:00 | 21:00:00 | | 1 | 3 | 11:00:00 | 21:00:00 | | 1 | 4 | 11:00:00 | 21:00:00 | | 1 | 5 | 17:00:00 | 23:30:00 | | 1 | 6 | 11:00:00 | 14:30:00 | open midday, closed 14:30 - 19:00 | 1 | 6 | 19:00:00 | 25:30:00 | open late Note 25:00 = 1am on next day | 1 | 7 | 19:00:00 | 22:30:00 | +---------------+------+----------+------------+ Note this allows for Days when the restaurant is not open Days when it closes during part of the day then reopens Is open past midnight I used to do a lot of timetable work for the transport industry and all-night buses would begin around 11pm and finish around 7am. For data consistency of always finishing after it started, and maintaining correct arithmetic of duty lengths, we adopted a 32 hour clock, so 7am on a night service was 31:00:00. You may need a similar device for late-closing restaurants.
  2. Using a similar function but making it recursive to search the directory tree. $dt = 0; $latestfile = ''; $latestdir = ''; $startDir = 'c:/inetpub/wwwroot'; // set start of search newestDir($startDir, $dt, $latestfile, $latestdir); // call search function echo "$latestdir/$latestfile : " . date('Y-m-d H:i:s', $dt); // output lastest dir/file function newestDir($dir, &$dt, &$latestfile, &$latestdir) { if ($p = opendir($dir) ) { while (false !== ($file = readdir($p))) { if ($file=='.' || $file=='..') continue; if (!is_dir("$dir/$file")) { if (($ft = filemtime("$dir/$file")) > $dt) { $dt = $ft; $latestdir = $dir; $latestfile = $file; } } else { newestDir("$dir/$file", $dt, $latestfile, $latestdir); } } } closedir($p); }
  3. If you get new user just add them to the end of the original list and rerun
  4. Don't you just love it when you search the internet for the same problem that you have only to find there is only the same problem but no solution?
  5. You have two identical stat history tables (champhorses for this year and champhorses2014 for last year). To get the maximum stat value for each horse you need to combine this data into one table - which is what the subquery with the UNION is doing. Having got the maxima for each horse, this subquery is then JOINED to match with each horse
  6. Or you can do it the SQL query SELECT lastupdate , timestampdiff(MINUTE, lastupdate, NOW()) as min_since FROM updates; +---------------------+-----------+ | lastupdate | min_since | +---------------------+-----------+ | 2015-07-12 13:20:10 | 14 | | 2015-03-12 13:30:10 | 175684 | | 2015-04-12 13:30:10 | 131044 | | 2015-05-12 13:30:10 | 87844 | | 2015-06-12 13:30:10 | 43204 | +---------------------+-----------+
  7. Instead of two history data tables (champhorses and champhorses2014) which have identical structure, combine and extract this year and previous year stats based on the date. However, as you currently have it you need a union of the two table to get the max values Something like this SELECT t1.Horse , t1.Track , t1.Race , t1.Jockey , t1.Trainer , t1.Owner , t1.Date , t2.perStart , t2.rank , t2.speedFigure , t3.perStart2014 , t3.rank2014 , t3.speedFigure2014 , maxps , maxrank , maxsf FROM champsintoday t1 LEFT JOIN champshorses t2 ON t1.HorseRef = t2.referenceNumber LEFT JOIN champshorses2014 t3 ON t1.HorseRef = t3.referenceNumber2014 INNER JOIN ( SELECT referenceNumber , MAX(perStart) as maxps , MAX(rank) as maxrank , MAX(speedFigure) as maxsf FROM ( SELECT referenceNumber , perStart , rank , speedFigure FROM champshorses UNION SELECT referenceNumber2014 , perStart2014 , rank2014 , speedFigure2014 FROM champshorses2014 ) as bothtbls GROUP BY referenceNumber ) as t4 ON t1.HorseRef = t4.referenceNumber WHERE t1.Date = CURDATE() ORDER BY t1.Date ASC, t1.track ASC, t1.Race ASC, t2.speedFigure DESC
  8. Explanation: The boolean expression "Status='expired'" evaluates to 0 or 1 SELECT variety , expiry , status , status='expired' as demo FROM vegetable ORDER BY status='expired', expiry; +----------+---------------------+---------+------+ | variety | expiry | status | demo | +----------+---------------------+---------+------+ | sprouts | 2015-07-05 21:53:57 | fresh | 0 | | cabbage | 2015-07-10 21:53:57 | rotten | 0 | | lettuce | 2015-07-11 21:53:57 | fresh | 0 | | cucumber | 2015-07-12 21:53:57 | rotten | 0 | | potato | 2015-07-08 21:53:57 | expired | 1 | | totmato | 2015-07-14 21:53:57 | expired | 1 | +----------+---------------------+---------+------+
  9. ORDER BY status='expired' , arrival_time
  10. Congratulations. Mine's a gin'n'tonic
  11. Your problem seems similar to this thread http://forums.phpfreaks.com/topic/296962-looping-is-making-me-loopy/
  12. Sorry about the form/fieldset. I spotted that after posting and moved the form tags. (It worked as it was but I noticed a warning when I viewed the html source in my IDE) <?=$example?> is shortcode for <?php echo $example;?> and is available from 5.4 list() requires a numerically indexed array, not an associative array. And yes, I omitted the error handling as my objective with the example was to show you how to handle the data.
  13. Read this thread http://forums.phpfreaks.com/topic/297236-get-magic-quotes-gpc-function-is-deprecated-some-help-please/
  14. Some explanation of the whole process would help. For example, is that data the result of a single call to the url or accumulated from several calls. If several, how are you storing it? Do you want individual total for every second or is it that the data comes in every second but you want the accumulated totals for the day/hour or whatever time period? That is JSON data so you might want to start by looking at json_decode()
  15. How to accomplish what? If the code isn't working (whatever not working means) it only shows us what you don't want too do.
  16. The section of code you posted above selects the profile record matching the user record. If there is no matching profile then those fields are null in the results. So if the userprofileid is found, the current data is displayed for editing. If not found, a blank form is displayed to add a profile. Line 11 is just to display "Add Profile" or "Edit Profile" in the fieldset legend. The getSkillset() function runs a query to get all the skillset descriptions and matches the skillset_id against the user_skillset to get the current levels for the user for each skillset. It then loops through the results creating a new div for each specialization, and these divs contain the list of skillsets for the specialisation with their radio buttons (the buttons checked according to the users current level) The javascript is to hide/show the div relating to the selected specialization. I am attaching a dump of my test database Dump20150709.txt
  17. It may look more complicated but if your coding follows the db structure it's easier and requires far less code. I have attached a sample form and update using the proposed structure. As you can see it saves you hundreds of lines of repetitive coding. I don't what you want in the portfolio table but it sounds as though you treat it the same way as have with the user_skillset records (one image name per row, each with the user_id). For brevity, I omitted the picture upload. beginner_profile.php beginner_update.php
  18. If you only want to send a single SMS, why are fetching records for everyone that has due due dates then checking each one for the $current_visitor? Make it a condition in the WHERE clauses so you only get the data you need. BTW, $current_visitor doesn't appear to be defined anywhere.
  19. Given the structure of the data in your form, I would suggest that that your DB structure should be +----------+ +-----------------------+ | user | | specialization | +----------+ +-----------------------+ | id (PK) | | specialization_id(PK) | | name | | description | | email | +-----------------------+ | username | | | password | +-------------------+ +-------------------+ | +----------+ | user_profile | | skillset | | | +-------------------+ +-------------------+ | | | userProfileId(PK) | | skillset_id(PK) | | | | user_id | | specialization_id |>---------------+ +-----------------| picname | | description | | introduction | +-------------------+ | contactno | | +-------------------+ | | | | | | | | +-----------------------+ | | | user_skillset | | | +-----------------------+ | +--------<| user_id(PK) |>-----+ | skillset_id(PK) | | level | +-----------------------+
  20. Your form is missing the "Submit" button. When I added that there were no problems. I did not get your timeout error.
  21. Works fine for me. Post the whole code from your "index.php"
  22. The select needs to be inside <form> tags (hence my previous link to php forms). When the form is submitted the contents are passed in the $_GET or $_POST arrays depending on the form method. (Use POST when sending data to perform an update and GET when you just want to get information) include("class.php"); if (isset($_GET['year'])) { $f = new february((int)$_GET['year']); $days = $f->numdays(); echo "There were $days days in February {$_GET['year']}<hr>"; } $cutoff = date(1900); $now = date('Y'); ?> <html> <body> <form method='get' action=''> <?php echo '<select name="year">' . PHP_EOL; for ($y=$now; $y>=$cutoff; $y--) { echo ' <option value="' . $y . '">' . $y . '</option>' . PHP_EOL; } echo '</select>' . PHP_EOL; ?> <input type='submit' name='btnSubmit' value='Submit'> </form> </body> </html>
  23. http://uk1.php.net/manual/en/tutorial.forms.php
  24. This should get all the info you need with a single query instead of all those separate ones SELECT id, sloc.name as start, startcompany, eloc.name as end, endcompany, cargoweight, dc.name as cargo, cargotype, time, cargodamage, drate.name as rating, distance, price, costs, screenshot, status price - costs - cargodamage as profit FROM drive_routes as dr INNER JOIN drive_locations as sloc ON dr.start = sloc.id INNER JOIN drive_locations as eloc ON dr.end = eloc.id INNER JOIN drive_cargo as dc ON dr.cargo = dc.id INNER JOIN drive_rating as drate ON dr.rating = drate.id WHERE driver = ". $_GET['id'] ."
×
×
  • 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.