Jump to content

hyster

Members
  • Posts

    252
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Age
    42

hyster's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

2

Community Answers

  1. I made a basic error :$ now I'm stuck with the following, noting happens but the code "executes" I'm trying to get when the person was last online in a weekly group, 7 - 14 - 21 -28 - over days days ago $timestamp = $output2['data'][$acc_id]['last_battle_time']; $my_date = date('Y-m-d',$timestamp); if( strtotime($my_date) >= strtotime('-1 day') && strtotime($my_date) <= strtotime('-7 day') ) { echo ' 7'; }elseif( strtotime($my_date) >= strtotime('-7 day') && strtotime($my_date) <= strtotime('-14 day') ) { echo ' 14'; }elseif( strtotime($my_date) >= strtotime('-14 day') && strtotime($my_date) <= strtotime('-21 day') ) { echo ' 21'; }elseif( strtotime($my_date) >= strtotime('-21 day') && strtotime($my_date) <= strtotime('-28 day') ) { echo ' 28'; }
  2. I'm trying to get an if statement to determine inbetween 2 dates. I can get it working if its older than -7 days (single argument) but when I try to add the 2nd condition I get syntax error $timestamp is coming from a json - unix timestamp $timestamp = $output2['data'][$acc_id]['last_battle_time']; $my_date = date('Y-m-d',$timestamp); if( strtotime($my_date) > strtotime('-7 day') && < strtotime('-14 day') ) { echo ' 7'; }
  3. thanks mac_gyver u asked enough question for me to look back over it and got it working with the correct type of query. I was modding a 4 year old script and I not really done any coding at all in 2 so I'm just a little behind :$ the problem I had was it was running the script with 0 errors, if I had errors I could have stumbled on from there lol
  4. I'm getting a json feed but with not all the data I want so I'm trying to pull the extra data from a sql table I already have. the insert query works fine but not the select query (the "cont" and "tip" is for testing) I don't no if the $tank_id in the select query is missing or if the whole query section just does not work the way I coded it thanks for any help. $count = '0'; foreach ($output['data'][$id] as $item){ // works fine $tank_id = $item['tank_id'] ; $master = $item['mark_of_mastery'] ; // does not seem to be working // get tank details from another table $show01 = mysql_query("SELECT * from tank_list where tank_id = '$tank_id' LIMIT 1"); $row01 = mysql_fetch_assoc($show01); $country = 'cont'.$row01['nation']; //cont for testing $type = 'tip'.$row01['type']; //tip for testing // works fine //insert players complete garage data $sql9="INSERT INTO garage_list ( country, type, player, account_id, tank_id, master)VALUES('$country', '$type', '$nick','$id','$tank_id', '$master')"; $count ++; if ($conn->multi_query($sql9) === TRUE) { //echo "New records created successfully, thanks " .$nick; } else { //echo "Error: " . $sql9 . "<br>" . $conn->error; } }
  5. hyster

    sql joins

    the 'clan' is number (500035013, 500017963), the name will be hard coded as only 7 clans will be used as its for an internal web page. date is for the last game played not when the data was updated currently the update script moves the data from 1 table to the next. so id be better doing it like this ?? acc_id - name - clan - date - sh_cur - sh_7 - sh_14 sh_21 sh_28 cw_cur - cw_7 - cw_21 - cw_28
  6. hyster

    sql joins

    I have 5 tables with identical layouts, the point being I have a snap shot of a players game stats for the previous 4 weeks. the tables will be used to work out how many games a player has had week by week. the search will pull "select * where clan = '123456' " use the ac_id to tie the tables but I need cw and sh from the 4 other tables the end result I'm after is name - past 7 - past 14 - past 21 - past 28 hyster - 10 - 15 - 23 - 30 play1 - 3 - 6 - 10 - 17 the problem I have is that I do not know what kinda join to use as none seem to work in phpmyadmin TABLES monitor acc_id - name -cw - sh - date - clan monitor_7 acc_id - name -cw - sh - date - clan monitor_14 acc_id - name -cw - sh - date - clan monitor_21 acc_id - name -cw - sh - date - clan monitor_28 acc_id - name -cw - sh - date - clan this returns null for the 4 tables so I don't know where I'm going wrong :/ pointers please if u would be so kind :$ SELECT * FROM 'monitor' where 'clan' = '123456' left JOIN monitor_7 ON monitor.acc_id=monitor_7.acc_id left JOIN monitor_14 ON monitor.acc_id=monitor_14.acc_id left JOIN monitor_21 ON monitor.acc_id=monitor_21.acc_id left JOIN monitor_28 ON monitor.acc_id=monitor_28.acc_id
  7. thanks requinix I found my problem, I was missing a = in the url :$
  8. I have a json data set that I'm trying to loop and echo but part of the dataset changes for each set of data. I'm stuck on the $data,[????][name_il8n] . how do I loop the part with the ???? when I just need the [name_il8n] data ?? sample of the dataset "status": "ok", "meta": { "count": 43 }, "data": { "92_stalingrad": { "name_i18n": "Stalingrad" }, "36_fishing_bay": { "name_i18n": "Fisherman's Bay" }, "05_prohorovka": { "name_i18n": "Prokhorovka" }, "101_dday": { "name_i18n": "Overlord" }, } code so far $jsonurl = "https://api.worldoftanks.eu/wot/encyclopedia/arenas/?application_id$app_id"; $json = file_get_contents($jsonurl,0,null,null); $output = json_decode($json, true); foreach ($output['data']['????']['name_i18n'] as $item){ echo "<option>".$item['name_i18n']."</option>"; } thanks for any help
  9. this is a data dump for my account, max users is 100 accounts, data is coming from a games API. the column headers will equal the same for the data ID other when its repeated id use clan_spotted regular_team_spotted company_spotted all_spotted and so on or if i used a separate table for each section then keep them as the origanal name { "status": "ok", "meta": { "count": 1 }, "data": { "502438129": { "client_language": "en", "last_battle_time": 1445732920, "account_id": 502438129, "created_at": 1329221187, "updated_at": 1445732980, "private": null, "ban_time": null, "global_rating": 6209, "clan_id": 500020315, "statistics": { "max_frags_tank_id": 52561, "clan": { "spotted": 60, "avg_damage_assisted_track": 81.71, "avg_damage_blocked": 426.05, "direct_hits_received": 355, "explosion_hits": 4, "piercings_received": 270, "piercings": 237, "xp": 50890, "survived_battles": 43, "dropped_capture_points": 118, "hits_percents": 68, "draws": 7, "battles": 104, "damage_received": 142066, "avg_damage_assisted": 275.33, "frags": 46, "avg_damage_assisted_radio": 193.62, "capture_points": 167, "hits": 392, "battle_avg_xp": 489, "wins": 42, "losses": 55, "damage_dealt": 113955, "no_damage_direct_hits_received": 85, "shots": 575, "explosion_hits_received": 33, "tanking_factor": 0.31 }, "max_xp_tank_id": 8193, "regular_team": { "spotted": 13, "avg_damage_assisted_track": 83.73, "max_xp": 1332, "avg_damage_blocked": 334.55, "direct_hits_received": 59, "explosion_hits": 1, "piercings_received": 36, "piercings": 36, "max_damage_tank_id": 2849, "xp": 5905, "survived_battles": 6, "dropped_capture_points": 6, "hits_percents": 81, "draws": 0, "max_xp_tank_id": 2849, "battles": 11, "damage_received": 9621, "avg_damage_assisted": 133.45, "max_frags_tank_id": 2849, "frags": 7, "avg_damage_assisted_radio": 49.73, "capture_points": 0, "max_damage": 1613, "hits": 65, "battle_avg_xp": 537, "wins": 3, "losses": 8, "damage_dealt": 11993, "no_damage_direct_hits_received": 23, "max_frags": 2, "shots": 80, "explosion_hits_received": 0, "tanking_factor": 0.35 }, "max_xp": 2304, "company": { "spotted": 350, "avg_damage_assisted_track": 124.71, "avg_damage_blocked": 0, "direct_hits_received": 103, "explosion_hits": 0, "piercings_received": 77, "piercings": 75, "xp": 247376, "survived_battles": 187, "dropped_capture_points": 478, "hits_percents": 60, "draws": 6, "battles": 470, "damage_received": 290064, "avg_damage_assisted": 260.88, "frags": 285, "avg_damage_assisted_radio": 136.17, "capture_points": 1048, "hits": 1178, "battle_avg_xp": 526, "wins": 313, "losses": 151, "damage_dealt": 289651, "no_damage_direct_hits_received": 26, "shots": 1961, "explosion_hits_received": 5, "tanking_factor": 0 }, "trees_cut": 12089, "all": { "spotted": 13359, "avg_damage_assisted_track": 84.28, "max_xp": 2304, "avg_damage_blocked": 246.9, "direct_hits_received": 42528, "explosion_hits": 4419, "piercings_received": 31962, "piercings": 42247, "max_damage_tank_id": 9297, "xp": 9818758, "survived_battles": 5639, "dropped_capture_points": 10632, "hits_percents": 60, "draws": 296, "max_xp_tank_id": 8193, "battles": 18481, "damage_received": 15620244, "avg_damage_assisted": 288.14, "max_frags_tank_id": 52561, "frags": 15342, "avg_damage_assisted_radio": 203.86, "capture_points": 32787, "max_damage": 7782, "hits": 105063, "battle_avg_xp": 531, "wins": 9477, "losses": 8708, "damage_dealt": 18136701, "no_damage_direct_hits_received": 10566, "max_frags": 8, "shots": 176205, "explosion_hits_received": 1665, "tanking_factor": 0.28 }, "stronghold_defense": { "spotted": 0, "max_frags_tank_id": null, "max_xp": 0, "direct_hits_received": 0, "explosion_hits": 0, "piercings_received": 0, "piercings": 0, "xp": 0, "survived_battles": 0, "dropped_capture_points": 0, "hits_percents": 0, "draws": 0, "max_xp_tank_id": null, "battles": 0, "damage_received": 0, "frags": 0, "capture_points": 0, "max_damage_tank_id": null, "max_damage": 0, "hits": 0, "battle_avg_xp": 0, "wins": 0, "losses": 0, "damage_dealt": 0, "no_damage_direct_hits_received": 0, "max_frags": 0, "shots": 0, "explosion_hits_received": 0, "tanking_factor": 0 }, "stronghold_skirmish": { "spotted": 30, "max_frags_tank_id": 4929, "max_xp": 958, "direct_hits_received": 101, "explosion_hits": 2, "piercings_received": 90, "piercings": 58, "xp": 7576, "survived_battles": 6, "dropped_capture_points": 3, "hits_percents": 59, "draws": 0, "max_xp_tank_id": 11553, "battles": 27, "damage_received": 21485, "frags": 4, "capture_points": 89, "max_damage_tank_id": 2849, "max_damage": 2381, "hits": 77, "battle_avg_xp": 281, "wins": 9, "losses": 18, "damage_dealt": 15536, "no_damage_direct_hits_received": 11, "max_frags": 1, "shots": 130, "explosion_hits_received": 2, "tanking_factor": 0.06 }, "historical": { "spotted": 0, "avg_damage_assisted_track": 0, "max_xp": 0, "avg_damage_blocked": 0, "direct_hits_received": 0, "explosion_hits": 0, "piercings_received": 0, "piercings": 0, "max_damage_tank_id": null, "xp": 0, "survived_battles": 0, "dropped_capture_points": 0, "hits_percents": 0, "draws": 0, "max_xp_tank_id": null, "battles": 0, "damage_received": 0, "avg_damage_assisted": 0, "max_frags_tank_id": null, "frags": 0, "avg_damage_assisted_radio": 0, "capture_points": 0, "max_damage": 0, "hits": 0, "battle_avg_xp": 0, "wins": 0, "losses": 0, "damage_dealt": 0, "no_damage_direct_hits_received": 0, "max_frags": 0, "shots": 0, "explosion_hits_received": 0, "tanking_factor": 0 }, "team": { "spotted": 69, "avg_damage_assisted_track": 67.39, "max_xp": 1515, "avg_damage_blocked": 0, "direct_hits_received": 260, "explosion_hits": 0, "piercings_received": 203, "piercings": 192, "max_damage_tank_id": 5377, "xp": 45516, "survived_battles": 35, "dropped_capture_points": 158, "hits_percents": 45, "draws": 0, "max_xp_tank_id": 5377, "battles": 74, "damage_received": 30255, "avg_damage_assisted": 110.22, "max_frags_tank_id": 5377, "frags": 27, "avg_damage_assisted_radio": 42.82, "capture_points": 391, "max_damage": 2691, "hits": 327, "battle_avg_xp": 615, "wins": 58, "losses": 16, "damage_dealt": 35223, "no_damage_direct_hits_received": 57, "max_frags": 3, "shots": 726, "explosion_hits_received": 0, "tanking_factor": 0 }, "max_damage_tank_id": 9297, "frags": null, "max_damage": 7782, "max_damage_vehicle": 9297, "max_frags": 8 }, "nickname": "Hyster", "ban_info": null, "logout_at": 1445732977 } } }
  10. thanks benanamen, I wasn't concerned with the amount of data per se but the amount of data for each entry (row). ill read up on database normalization, cheers
  11. I have a database I want to build, unfortunately it has about 320 records I need to insert per user but max user count of 100, this seems a massive amount of data for a single table row so 2 questions. what is the max practicable amount of records per table row ?? (is it based on column count or actual character count ?) am I best cutting it up into relevant sections? (pretty sure the answer is yes though) thanks guys
  12. its close to what im after, i tried to add a pic but it wouldn't let me before. the idea is that u click the green dot to select the tank, the green dot then has a red bg to show thats the 1 selected (2nd click to de-select it), the column colour then goes pink so when ur scrolling lower than the selected item u can still see the column has been chosen further up. there was no th before as the player names was 1 table and the grid was a 2nd, i tried to have a sticky th in a single table with the names but i could not get that to work
  13. im try to get the cell to be 1 color and the column to another color on click. I can get the cell to do it and I have found code that should do both but I cant work out how to use it or im doing it wrong. this works for the cell bgcolor <script type="text/javascript"> function changeColor(elem){ var cellcolor = elem.style.backgroundColor; if(!(cellcolor == 'red')){ elem.style.backgroundColor = "red"; } else{ elem.style.backgroundColor= ""; } } </script> and I want to change it with this code for the cell and column bg color <script type="text/javascript"> $(document).ready(function(){ $('td').click(function(){ _index = $(this).index(); $(this).addClass('red'); $('table th:eq(' + _index + '), table td:eq(' + _index + ')').addClass('pink'); //This line adds class red to the clicked cell and adds class pink to collumn of the clicked cell }); }); </script> full page code <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> <script type="text/javascript"> function changeColor(elem){ var cellcolor = elem.style.backgroundColor; if(!(cellcolor == 'red')){ elem.style.backgroundColor = "red"; } else{ elem.style.backgroundColor= ""; } } </script> </head> <style> .top1{ background-color:yellow; } .left { float: left; text-align: center; background-color: #fff; border-radius: 25px; border: 2px solid #8AC007; padding-left: 5px; width: 100px; margin: auto; } .right { float: right; text-align: center; background-color: #fff; border-radius: 25px; border: 2px solid #8AC007; padding: 1px; width: 25px; margin: auto; text-align: center; } .name{ background-color:green; } .tank{ background-color:green; } .name td:first-child { background-color:blue; width: 180px; } .tank td:first-child{ background-color:blue; width: 180px; } .tank tr{ background-color: yellow; } .tank td{ width: 20px; } .tank tr:hover { background-color:#aaa; } .name tr { background-color: yellow; width: 20px; } .tlist{ overflow-y: scroll; height:700px; top:20px; } .players{ position: static; } </style> <table class="top1" align="center"><tr><td><a href="./pick_clan.php">back to selection</a></td></tr></table></br> <?php //db connection data include './include/config.php'; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } @$clanname = $_POST['clanname']; @$tier = $_POST['tier']; @$map = $_POST['map']; @$invite = implode(', ',$_POST['player']); $player1 = '('.$invite.')'; ?> <div class="players"> <table class="name" > <?php $sql = "SELECT tank_list.name_i18n, tank_list.tank_id, tank_list.name, tank_list.image, tank_list.short_name_i18n, player_list.account_id, player_list.nickname, player_list.clan, garage_list.master, garage_list.tank_id IS NOT NULL AS combination_exists FROM player_list CROSS JOIN tank_list LEFT JOIN garage_list ON player_list.account_id = garage_list.account_id AND tank_list.tank_id = garage_list.tank_id WHERE player_list.nickname IN $player1 AND tank_list.level = '$tier' AND player_list.clan = '$clanname' ORDER BY FIELD(tank_list.type, 'lighttank', 'mediumTank', 'heavyTank', 'AT-SPG', 'SPG'), name ASC, tank_list.name ASC, tank_list.nation ASC, player_list.nickname ASC "; $result = $conn->query($sql); $rows = $result->fetch_all(MYSQLI_ASSOC); $data = array(); foreach ($rows as $row) { $data[$row['image']][$row['nickname']] = ($row['combination_exists'] == 1); } if(empty($data)){ echo "Please select again, no players found matching your search"; } else { $firstTank = reset($data); $players = array_keys($firstTank); $array = array_keys($firstTank); $count = count($array); ?> <tr><td class="first"> <div id="pageone" data-role="main" class="ui-content"> <a href="#myPopup" data-rel="popup" data-position-to="window"> <img src="./img/maps/<?php echo $map ; ?>.jpg" alt="<?php echo $map ; ?>" style="width:100px;"></a> <div data-role="popup" id="myPopup"> <p><?php echo $map ; ?></p> <a href="#pageone" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a><img src="./img/maps/<?php echo $map ; ?>.jpg" style="width:800px;height:800px;" alt="<?php echo $map ; ?>"> </div> </td> <?php for ($i = 0; $i < $count; $i++) { echo '<td><img src="./img/name/vrt'.$array[$i].'.png" title="'.$array[$i].'"></td>'; //echo "<td>".$array[$i] . "\n</td>"; } ?> </tr> </table> </div> <div class="tlist"> <table class="tank" > <?php foreach($data as $tank_name=>$arr){ echo '<tr><td class="first"><div class="left"><img src="./img/tank/'.$tank_name. '"></div><div class="right">' . array_sum($arr).'</div></td>'; // tank name as row label foreach($arr as $nickname=>$element){ // output the data for each cell if ($element == 1){ ///////////////// //ONCLICK IS HERE ///////////////// echo '<td onclick="changeColor(this)"><img src="./img/' . $element . '.png" height="20" width="20" title="'.$nickname . '"></td>'; }else{ echo "<td></td>"; } } //echo '</tr>'; // may use this later echo '<td><div class="right">'. array_sum($arr) .'</div></td></tr>'; } } ?> </tbody> </table></div>
  14. $row['id'] is not inside php so its showing it as plain text <td><a href="edit-customer.php?id=' . $row['id'] . '">Edit</a></td> <td><a href="delete.php?id=' . $row['id'] . '" onClick="return confirm('."'Are you sure you want to delete this record?');".'">Delete</a></td> to <td><a href="edit-customer.php?id="<?php echo $row['id'] ?>">Edit</a></td> <td><a href="delete.php?id="<?php echo $row['id'] ?>" onClick="return confirm('."'Are you sure you want to delete this record?');".'">Delete</a></td> should work
×
×
  • 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.