Jump to content

hyster

Members
  • Posts

    252
  • Joined

  • Last visited

Everything posted by hyster

  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
  15. without looking at the code yes, php needs to be interpreted before it can be displayed in a browser as html code. a html file is already html so can be opened directly in a browser
  16. u have to run a .php file from inside a webserver not from ur pc (unless u have a web server installed on ur pc)
  17. changed css to use class's css is in a block at the top, (will be moved to a css file when im done) fixed the ' and " (I hope) $row['type'] holds 1 of 5 values which im going to use to change the bgcolor final </tr> I missed putting back in as I was experimenting having it at the start and end of the row :$ $row['type'] still holding the last row value and not the row value (still too dumb to work out what im missing) applying for a bank loan to pay for the beer I owe mac_gyver <div style=' height:800px; overflow:auto;'> <table class='hovertable' cellspacing'0' cellpadding='0' border='1' > <thead> <?php $sql = "SELECT tank_list.name_i18n, tank_list.tank_id, tank_list.name, tank_list.type, tank_list.nation, tank_list.short_name_i18n, player_list.account_id, player_list.nickname, player_list.clan, 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 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['short_name_i18n']][$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); echo '<tr><th width="170" ></th>'; for ($i = 0; $i < $count; $i++) { echo '<th><img src="./img/name/vrt'.$array[$i].'.png" title="'.$array[$i].'"></th>'; //echo "<td>".$array[$i] . "\n</td>"; } echo '</tr></thead></div><tbody>'; foreach($data as $tank_name=>$arr){ echo '<tr><td><div class="'.$row['type'].'">'.$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){ echo '<td><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>
  18. sorry but I have been fiddling again and got stuck with the styling using vars for colours for the CSS:/ the data matches tank_list :: name - type so I thought it be as simple as adding $row['type'] to create the div id for the css in the foreach but its only echoing the last entry not looping as I thought it would. I did as suggested and created the whole table from the single query this time 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); echo "<tr><th></th>"; for ($i = 0; $i < $count; $i++) { echo "<th><img src='./img/name/vrt".$array[$i].".png' title=".$array[$i]."></th>"; //echo "<td>".$array[$i] . "\n</td>"; } echo "</tr></thead></div><tbody>"; foreach($data as $tank_name=>$arr){ echo "<tr><td width='167'><div id='".$row['type']."'>".$tank_name . "</div><div id='right'>" . array_sum($arr)."</div></td>"; // tank name as row label foreach($arr as $nickname=>$element){ if ($element == 1){ echo "<td><img src='./img/{$element}.png' height='20' width='20' title='$nickname'></td>"; }else{ echo "<td></td>"; } } //echo "<td>". array_sum($arr) ."</td></tr>"; } }
  19. massive thanks mac_giver (along with barand I owe u a few beers) im in way over my head with what im doing atm (I didn't see the last post on the previous post or I would have tried that). I can only learn buy messing with code till I get it doing what I need, I can not follow most tutorials as I find them bloated and I lose the tree's in the forest. the SQL query is more than what I need as I was experimenting with adding additional data. I did have 2 images but was told it made it harder to read so I just used the 1.png. as for the @ I only use them as a short cut, I would fix the errors once I had the code working, I know its bad practice but to me its the easiest way.
  20. I have some code that works other the last TD in the table is not displaying. the last td in the row does a count of occurrences in the row of $row["combination_exists"]' I can not work out where to put the $count for the last row - TD. thanks $sql = "SELECT tank_list.name_i18n, tank_list.tank_id, tank_list.name, tank_list.short_name_i18n, player_list.account_id, player_list.nickname, player_list.clan, 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 tank_list.level = '$tier' AND player_list.clan = '$clanname' ORDER BY tank_list.type ASC, tank_list.name ASC, tank_list.nation ASC, player_list.nickname ASC "; $result = $conn->query($sql); $lastval = 0; $count = 0; if (@$result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { // 1st td - 1st row if ($lastval == "0"){ $lastval = $row["name_i18n"]; echo "<tr><td width='167'>".$row["short_name_i18n"]."</td>"; } // rest of td 1st td if ($row["name_i18n"] != $lastval){ //all other rows $lastval = $row["name_i18n"]; //works for all but last row - last td if ($row["name_i18n"] != $lastval){ $lastval = $row["name_i18n"]; //echo "<td>". $count ."</td></tr>"; $count = 0; }else{ echo "<td>". $count ."</td></tr>"; $count = 0; } echo "</tr><td width='167'>".$row["short_name_i18n"]."</td>"; } // status of tank -- fills out a table row if ($row["name_i18n"] != $lastval){ $lastval = $row["name_i18n"]; echo "<td><img src='./img/".$row["combination_exists"].".png' height='20' width='20' title=".$row["nickname"]."></td>"; if ($row["combination_exists"] == '1'){ $count++; } }else{ echo "<td><img src='./img/".$row["combination_exists"].".png' height='20' width='20' title=".$row["nickname"]."></td>"; if ($row["combination_exists"] == '1'){ $count++; } } } } else { echo "Please selct again, no players found matching your search"; } if (@$row["combination_exists"] == '1'){ @$count++; } $conn->close(); ?> </table>
  21. sorry copied the wrong code Select Count(Distinct tank_id) As counttanks , Count(tank_id) As counttanks , tank_id As tank_id From garage_list RIGHT JOIN player_list ON player_list.account_id = garage_list.account_id RIGHT JOIN tank_list ON player_list.tank_id = tank_list.tank_id Group By tank_id where tank_list.level='8', and player_list.clan='BAD-1' and player_list.account_id = '500549663' TABLES <garage_list> account_id :: tank_id 1234 :: 20 1234 :: 44 4321 :: 18 <tank_list> Tank_id :: name :: long_name :: row1 :: row2 :: row3 :: 20 :: sherman::usa_sher <player_list> account_id :: clan :: nickname 1234 ::bad-1:: joker 4321 ::bad-g :: grumpy
  22. I put the group by there as the garage_list:account_id is not a unique value. I need to count the instances and pass a unique value to the rest of the query Select Count(Distinct tank_id) As counttanks , Count(tank_id) As counttanks , tank_id As tank_id From garage_list RIGHT JOIN garage_list ON player_list.account_id = garage_list.account_id RIGHT JOIN garage_list ON player_list.account_id = garage_list.account_id Group By tank_id where tank_list.level='8', and player_list.clan='BAD-1' and player_list.account_id = '500549663'
  23. the count part works ok but it fails on the joins, the examples / tutorials I have read look like I have done, but I didn't find 1 with the count in front of it. the aim is for a table like this. level = 8 tank count <alt text on count> IS-3 3 player 1, player2, player 3 E-100 2 player1, player 4 thanks for any help Select Count(Distinct tank_id) As counttanks , Count(tank_id) As counttanks , tank_id As tank_id From garage_list Group By tank_id // upto here it works right JOIN tank_list on garage_list:tank_id = tank_list:tank_id right JOIN player_list on garage_list:account_id = player_list:account_id where tank_list.level='8', and player_list.clan'some-name' TABLES <garage_list> account_id :: tank_id <tank_list> Tank_id :: name :: long_name :: row1 :: row2 :: row3 :: <player_list> account_id :: clan :: nickname
  24. thanks again scootstah, ur a star just encase any1 else has need for this , this is my final code to create a transparent png overlaid with text, rotate 90 deg and save to a folder <?php $nick = 'some source'; $img=imagecreatetruecolor(100,20); imagealphablending($img,false); $col=imagecolorallocatealpha($img,255,255,255,127); imagefilledrectangle($img,0,0,180,20,$col); imagealphablending($img,true); $degrees = 90; //rotate image $font=$_SERVER["DOCUMENT_ROOT"].'./Arial.ttf'; $color = imagecolorallocate($img, 0, 0, 0); imagettftext($img,11,0,5,14,$color,$font,$nick); imagealphablending($img,false); imagesavealpha($img,true); $img1 = imagerotate($img, $degrees, 0); imagepng($img1, "./img/name/$nick.png"); imagedestroy($img); ?>
×
×
  • 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.