Jump to content

Barand

Moderators
  • Posts

    24,612
  • Joined

  • Last visited

  • Days Won

    834

Everything posted by Barand

  1. try SELECT d.Latitude AS departure_lat , d.Longitude AS depatrure_lng , a.Latitude AS arrival_lat , a.Longitude AS arrival_lng FROM rosters INNER JOIN airport a ON a.IATA = rosters.Arr INNER JOIN airport d ON d.IATA = rosters.Dep WHERE rosters.Arr = 'CRL' AND rosters.Dep = 'BGY'
  2. You cannot mix mysql_ and mysqli_ functions, Use just mysqli_ library.
  3. Disregard my last post, I understand your data array structure now. This "works" but I don't know what results you are expecting. <?php $colors = [ [ 'color'=> '# 000000 '], [ 'color'=> '# 97233F '], [ 'color'=> '# 841F27 '], [ 'color'=> '# A71930 '], [ 'color'=> '# EF0107 '], [ 'color'=> '# 94BEE5 '], [ 'color'=> '# CE1141 '], [ 'color'=> '# E13A3E '], [ 'color'=> '# DF4601 '], [ 'color'=> '# 241773 '], [ 'color'=> '# 008348 '], [ 'color'=> '# BD3039 '], [ 'color'=> '# 061922 '], [ 'color'=> '# 00338D '], [ 'color'=> '# 002E62 '], [ 'color'=> '# 8CCCE5 '], [ 'color'=> '# E03A3E '], [ 'color'=> '# 0085CA '], [ 'color'=> '# 1D1160 '], [ 'color'=> '# 034694 '], [ 'color'=> '# 0B162A '], [ 'color'=> '# E3263A '], [ 'color'=> '# CC3433 '], [ 'color'=> '# AF2626 '], [ 'color'=> '# AA002C '], [ 'color'=> '# C6011F '], [ 'color'=> '# FB4F14 '], [ 'color'=> '# 860038 '], [ 'color'=> '# E31937 '], [ 'color'=> '# 8B2942 '], [ 'color'=> '# 91022D '], [ 'color'=> '# 333366 '], [ 'color'=> '# 00285C '], [ 'color'=> '# 1B458F '], [ 'color'=> '# 002244 '], [ 'color'=> '# 007DC5 '], [ 'color'=> '# 006A4E '], [ 'color'=> '# 4D90CD '], [ 'color'=> '# 005A8B '], [ 'color'=> '# ED174C '], [ 'color'=> '# EC1F26 '], [ 'color'=> '# 0C2C56 '], [ 'color'=> '# 003777 '], [ 'color'=> '# 274488 '], [ 'color'=> '# CF0032 '], [ 'color'=> '# C8213F '], [ 'color'=> '# FDB927 '], [ 'color'=> '# 203731 '], [ 'color'=> '# 002D62 '], [ 'color'=> '# F36600 '], [ 'color'=> '# 03202F '], [ 'color'=> '# F5A12D '], [ 'color'=> '# FFC633 '], [ 'color'=> '# 002C5F '], [ 'color'=> '# E31837 '], [ 'color'=> '# 004687 '], [ 'color'=> '# FDBE11 '], [ 'color'=> '# 00A398 '], [ 'color'=> '# BA0021 '], [ 'color'=> '# EF3E42 '], [ 'color'=> '# 00245D '], [ 'color'=> '# 5CBFEB '], [ 'color'=> '# DA020E '], [ 'color'=> '# 0F586C '], [ 'color'=> '# 008E97 '], [ 'color'=> '# 98002E '], [ 'color'=> '# FF6600 '], [ 'color'=> '# 0A2351 '], [ 'color'=> '# 00471B '], [ 'color'=> '# 005083 '], [ 'color'=> '# 002B5C '], [ 'color'=> '# 4F2683 '], [ 'color'=> '# 025736 '], [ 'color'=> '# BF2F38 '], [ 'color'=> '# 122089 '], [ 'color'=> '# FDBB2F '], [ 'color'=> '# 0A2141 '], [ 'color'=> '# 9F8958 '], [ 'color'=> '# 6CADDF '], [ 'color'=> '# 0B2265 '], [ 'color'=> '# 00529B '], [ 'color'=> '# 006BB6 '], [ 'color'=> '# FF5910 '], [ 'color'=> '# 0161AB '], [ 'color'=> '# D50031 '], [ 'color'=> '# E4002B '], [ 'color'=> '# 00B6F1 '], [ 'color'=> '# 003831 '], [ 'color'=> '# A5ACAF '], [ 'color'=> '# 007DC3 '], [ 'color'=> '# 633492 '], [ 'color'=> '# E4173E '], [ 'color'=> '# 004953 '], [ 'color'=> '# F47940 '], [ 'color'=> '# 284898 '], [ 'color'=> '# 001B2D '], [ 'color'=> '# E56020 '], [ 'color'=> '# FDB827 '], [ 'color'=> '# 004812 '], [ 'color'=> '# 005CAB '], [ 'color'=> '# A50531 '], [ 'color'=> '# 724C9F '], [ 'color'=> '# BAC3C9 '], [ 'color'=> '# 05143F '], [ 'color'=> '# AA0000 '], [ 'color'=> '# FD5A1E '], [ 'color'=> '# 0051BA '], [ 'color'=> '# 05535D '], [ 'color'=> '# 4F8A10 '], [ 'color'=> '# ED1A3B '], [ 'color'=> '# 91B0D5 '], [ 'color'=> '# 0546A0 '], [ 'color'=> '# C41E3A '], [ 'color'=> '# EB172B '], [ 'color'=> '# D50A0A '], [ 'color'=> '# 013E7D '], [ 'color'=> '# 092C5C '], [ 'color'=> '# C0111F '], [ 'color'=> '# 134A8E '], [ 'color'=> '# D80016 '], [ 'color'=> '# 001C58 '], [ 'color'=> '# 07346F '], [ 'color'=> '# 12264C '], [ 'color'=> '# CF132B '], [ 'color'=> '# AB0003 '], [ 'color'=> '# 773141 '], [ 'color'=> '# 091453 '], [ 'color'=> '# 60223B '], [ 'color'=> '# 91764B '], [ 'color'=> '# 023474 '], [ 'color'=> '# 7A003C '], [ 'color'=> '# 13274F '], [ 'color'=> '# C4D600 '], [ 'color'=> '# FFC422 '], [ 'color'=> '# BB9753 '], [ 'color'=> '# 0D2B56 '], [ 'color'=> '# E03A3F '], [ 'color'=> '# 565A5C '], [ 'color'=> '# B95915 '], [ 'color'=> '# B1BABF '], [ 'color'=> '# C60C30 '], [ 'color'=> '# FAB383 '], [ 'color'=> '# A9B0B8 '], [ 'color'=> '# 313F49 '], [ 'color'=> '# 20385B '], [ 'color'=> '# D7A22A '], [ 'color'=> '# BEC0C2 '], [ 'color'=> '# FFD200 '], [ 'color'=> '# 8177B7 '], [ 'color'=> '# BCBEC0 '], [ 'color'=> '# FFE600 '], [ 'color'=> '# EEE3C7 '], [ 'color'=> '# 231F20 '], [ 'color'=> '# 8A8D8F '], [ 'color'=> '# F0B83D '], [ 'color'=> '# C4CED3 '], [ 'color'=> '# F9A01B '], [ 'color'=> '# 00539B '], [ 'color'=> '# FF7900 '], [ 'color'=> '# B4975A '], [ 'color'=> '# 5B2B2F '], [ 'color'=> '# 006778 '], [ 'color'=> '# C09A5B '], [ 'color'=> '# 0053A0 '], [ 'color'=> '# D00027 '], [ 'color'=> '# 003263 '], [ 'color'=> '# 005A9C '], [ 'color'=> '# 004689 '], [ 'color'=> '# AFB7BA '], [ 'color'=> '# 552582 '], [ 'color'=> '# FFCE65 '], [ 'color'=> '# FFE500 '], [ 'color'=> '# 7399C6 '], [ 'color'=> '# F58220 '], [ 'color'=> '# 0077C8 '], [ 'color'=> '# B6922E '], [ 'color'=> '# F0EBD2 '], [ 'color'=> '# 00A94F '], [ 'color'=> '# D31145 '], [ 'color'=> '# FFC62F '], [ 'color'=> '# BF2B37 '], [ 'color'=> '# 213770 '], [ 'color'=> '# 00285E '], [ 'color'=> '# F57D31 '], [ 'color'=> '# F58426 '], [ 'color'=> '# 002D72 '], [ 'color'=> '# E6393F '], [ 'color'=> '# 012055 '], [ 'color'=> '# 003087 '], [ 'color'=> '# BBBDBF '], [ 'color'=> '# EFB21E '], [ 'color'=> '# F05133 '], [ 'color'=> '# FDE192 '], [ 'color'=> '# E81828 '], [ 'color'=> '# B18500 '], [ 'color'=> '# D1BD80 '], [ 'color'=> '# EBE72B '], [ 'color'=> '# 013474 '], [ 'color'=> '# 8E9090 '], [ 'color'=> '# 0073CF '], [ 'color'=> '# B3995D '], [ 'color'=> '# F38F20 '], [ 'color'=> '# 005C5C '], [ 'color'=> '# 69BE28 '], [ 'color'=> '# 11568C '], [ 'color'=> '# 211E1F '], [ 'color'=> '# FFC325 '], [ 'color'=> '# 000066 '], [ 'color'=> '# 1B449C '], [ 'color'=> '# A68A26 '], [ 'color'=> '# 34302B '], [ 'color'=> '# 8FBCE6 '], [ 'color'=> '# 4B92DB '], [ 'color'=> '# 003278 '], [ 'color'=> '# 1D2D5C '], [ 'color'=> '# 047A4A '], [ 'color'=> '# 00214E '], [ 'color'=> '# 11225B '], [ 'color'=> '# F7C240 '], [ 'color'=> '# 0168AB '], [ 'color'=> '# EF5225 '], [ 'color'=> '# FFB612 '], [ 'color'=> '# EFE1C6 '], [ 'color'=> '# E3D4AD '], [ 'color'=> '# 9C824A '], ]; foreach ($colors as $k => $color) { $colors[$k]['color'] = str_replace(' ', '', $color['color']); $colors[$k]['hsl']= hexToHsl($color['color']); } // // now sort the colors array by HSL value // usort($colors, function ($a, $b) { $dh = 100*($a['hsl']['h']) - 100*($b['hsl']['h']); if ($dh==0) { $ds = 100*($a['hsl']['s']) - 100*($b['hsl']['s']); if ($ds==0) { return 100*($a['hsl']['l']) - 100*($b['hsl']['l']); } else return $ds; } else return $dh; }); /** * Convert a hexadecimal color in RGB * @param string $hex * @return array */ function hexToHsl($hex){ list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x"); return rgbToHsl($r, $g, $b); } /** * Convert a RGB color in its HSL value * @param int $r red * @param int $g green * @param int $b blue * @return array */ function rgbToHsl($r, $g, $b) { $r /= 255; $g /= 255; $b /= 255; $max = max($r, $g, $b); $min = min($r, $g, $b); $h = 0; $l = ($max + $min) / 2; $d = $max - $min; if ($d == 0) { $h = $s = 0; // achromatic } else { $s = $d / (1 - abs(2 * $l - 1)); switch ($max) { case $r: $h = 60 * fmod((($g - $b) / $d), 6); if ($b > $g) { $h += 360; } break; case $g: $h = 60 * (($b - $r) / $d + 2); break; case $b: $h = 60 * (($r - $g) / $d + 4); break; } } return array('h' => round($h, 2), 's' => round($s, 2), 'l' => round($l, 2)); } /** * Check if two hues are in the same given interval * @param float $hue1 * @param float $hue2 * @param int $interval * @return bool */ function huesAreinSameInterval($hue1, $hue2, $interval = 30){ return (round(($hue1 / $interval), 0, PHP_ROUND_HALF_DOWN) === round(($hue2 / $interval), 0, PHP_ROUND_HALF_DOWN)); } ?> <html> <head> <title>Colors</title> <style type="text/css"> .clr { width: 20px; height: 20px; float: left; } </style> </head> <body> <?php foreach ($colors as $k=>$col) { $c = $col['color']; echo "<div class='clr' style='background-color: $c'> </div>\n"; if ( ($k+1)%15==0) echo "<div style='clear:left'></div>"; } ?> </body> </html>
  4. this will convert your existing $colors array to a simple indexed array ($newcolors) $newcolors = array(); foreach ($colors as $color) { $newcolors[] = str_replace(' ', '', $color['color']); }
  5. You started out acknowledging there was a problem with your current structure so I gave you a solution. Now you say you want to stick with that crap. problematic design and get someone to bail you out. Perhaps someone else will.
  6. From what you have described you would want four tables (see attached model) video tag video_tag (to store the tags for each video) click (to log each click of a video's tag)
  7. That's an interesting list of optional solutions but, having read it three times, I still no no idea of what you are trying to achieve. What are you trying to do?
  8. I'd use a multiple insert query and batch in 1,000 rows at a time. EG INSERT INTO tablename (col1, col2, col3) VALUES (1, 2, 'aaa'), (2, 2, 'bbb'), (3, 2, 'ccc'), (4, 3, 'ccc'), (5, 4, 'aaa'), . . . (1000, 1, 'xyz');
  9. Good luck with that request. I asked for information 9 days ago but was totally ignored.
  10. Supposing you have, this (where you said some could be empty) $_POST['item_meta'][124] = 'aaa'; $_POST['item_meta'][125] = 'bbb'; $_POST['item_meta'][126] = 'ccc'; $_POST['item_meta'][127] = 'ddd'; $_POST['item_meta'][128] = 'eee'; $_POST['item_meta'][129] = ''; $_POST['item_meta'][130] = 'fff'; $_POST['item_meta'][131] = ''; $_POST['item_meta'][132] = ''; $_POST['item_meta'][133] = 'ggg'; then to get the $meta_value, all you need is $meta_value = join(',', array_filter($_POST['item_meta'])); to check echo $meta_value; //--> aaa,bbb,ccc,ddd,eee,fff,ggg
  11. try UPDATE ballot INNER JOIN ( SELECT username , COUNT(neptune) as ncount FROM ballot GROUP BY username HAVING ncount > 5 ) n USING (username) SET morethan5 = 'yes' However, it is bad practice to store derived data like that in a db table.
  12. Put "yes" inside single quotes so SQL knows it is a string literal and not a column name ... set morethan5 = 'yes' ...
  13. You can easily get the time diff while you query the data. It looks, from your code, like you store the time as an integer unix timestamp. It is much better to us DATETIME type columns (yyyy-mm-dd hh:ii:ss) so you don't have to convert them every time you use them, plus you can read them. Here's an example of getting the time diff in hours from a unix timestamp SELECT thetime as unixtime , FROM_UNIXTIME(thetime) as realtime , NOW() as timenow , timestampdiff(HOUR, FROM_UNIXTIME(thetime)+INTERVAL 10 HOUR, NOW()) as diff FROM test_time; +------------+---------------------+---------------------+------+ | unixtime | realtime | timenow | diff | +------------+---------------------+---------------------+------+ | 1453276800 | 2016-01-20 08:00:00 | 2016-01-20 09:48:25 | -8 | | 1453284000 | 2016-01-20 10:00:00 | 2016-01-20 09:48:25 | -10 | +------------+---------------------+---------------------+------+ 2 rows in set (0.00 sec)
  14. date_diff() takes two DateTime objects as parameters and returns a DateInterval object http://uk1.php.net/manual/en/datetime.diff.php
  15. and there is a single quote missing after '$des As my signature says, stop using mysql_ functions and use mysqli_ or PDO mysqli_ has now been removed from PHP.
  16. Sanitize - protect from sql injection attacks. Best way is use prepared queries. With a mysqli connection ($mysqli) you would $element = "UPDATE TableToUpdate SET newUpdateData = ? WHERE ID = ?"; $stmt = $mysqli->prepare($element); $stmt->bind_param('si', $value, $key); foreach($combine as $key => $value) { $stmt->execute(); }
  17. Use the id as the index for the array of form items. For example <input type='text' name='description[$id]' value='$description' > Then when you process the POST data foreach ($_POST['description'] as $id => $description) { // update description where id is $id }
  18. Does that last query give the correct results that should be inserted into tableC?
  19. With a single record (slab) then to get "1" for every week for the year you would need to create a "week" table and left join lot ON weekno. At present you only get weeks for which there is data
  20. FooKelvin, I have attached a data model to get you started. You should employ this same approach to your problem your other topic at http://forums.phpfreaks.com/topic/300461-generate-report-from-check-box-value-comments/?do=findComment&comment=1529890
  21. What a brilliant example of exactly how db tables should NOT be structured. Relational db tables are not spreadsheets. As soon as you see column names like "Question1, Question2,...,QuestionN", alarm bells ring. Take a course on data normalization. Store Yes/No values as 1/0.
  22. Does this version give you the same problem? If so, post your revised data. benanamen_1.php benanamen_2.php date_opt_funcs.php
  23. You may have only 3 but joining to a table with >1 matching records can increase that. You check slab date is within the date range but what about dried_in and complete dates?
  24. SELECT @wk:=0 as init0 , @day1 := '2015-10-11' as init1 , @day2 := '2016-01-09' as init6 . . .
×
×
  • 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.