Jump to content

saynotojava

Members
  • Content Count

    38
  • Joined

  • Last visited

Community Reputation

0 Neutral

About saynotojava

  • Rank
    Member
  1. They share common values, like Value1 is same as Value3 and Value2 is same as Value4. They also share datetime column which is same. And here is some data output example:: Table1 Table2 Value1 A Value2 fror Value3 A Value4 fror Value1 B Value2 frbo Current code counts number of each duplicates, in this case first query number of values A/fror in Table1 , and same in Table2. In case table2 does not contain anything .then i show it as zero. So end result look like this: A Fror 500 2 -In first table there 500 entries with value A Fror, while in second two B frbo 100 0-In first table there is 100 entires with value B frbo, while second does not contain anything
  2. Ok here is full currently working code with 2 queries, and goal is to have only one query instead. $result = $conn->query("SELECT `Table1`.Value1, `Table1`.Value2, count(*) AS count,SUM(Co) AS sum FROM `Table1` WHERE `Table1`.`Dt` between '2019-08-27 00:00:00' AND '2019-08-27 23:59:59' GROUP BY `Table1`.Value1, `Table1`.Value2 ; "); echo' <table class="zui-table zui-table-highlight-column"> <thead> <tr> <th>Value1</th> <th>Value2</th> </tr> </thead> <tbody>'; while($row = $result->fetch_assoc()) { $str = $row['Value1']; $str = strtoupper($str); echo" <tr> <td>echo $str</td> <td>echo {$row['Value2']}\"></td> <td>{$row['count']}</td> <td> "; $resultb = $conn->query("SELECT `Table2`.Value3, `Table2`.Value4, SUM(Payout) AS count , count(*) AS mu FROM `Table2` WHERE `Table2`.`Dt` between '2019-08-27 00:00:00' AND '2019-08-27 23:59:59' GROUP BY `Table2`.Value3, `Table2`.Value4 ; "); if ($resultb->num_rows > 0) { while($rowb = $resultb->fetch_assoc()) { $amo=substr($rowb['count'], 0, 5); echo $amo; $numb = $rowb['mu']; } } else { } echo " </td> <td>"; echo" </td> <td></td> <td> "; echo" </td> <td>"; echo"</td> <td> "; echo" </td> </tr> "; } echo' </tbody> </table>
  3. Visits thing was error, updated post to properly show first query(it's table1 instead). Also, Using Left/Right Union was one was with which i tried to solve it, does not need to be same method but it seems it does what i trying to accomplish. At the moment i loop query with table2 , and when there is no result, i output it as zero.
  4. I have two mysql queries , where currently i run second query by loop, so would like to reduce loading time by making single query. However, it seems there is some issue with WHERE clause which i can put it into only one query when using LEFT/RIGHT JOIN with Union and i use WHERE in both queries. Here is queries: SELECT `Table1`.Va, `Table1`.Va2, count(*) AS count,SUM(Co) AS sum FROM `Table1` WHERE `Table1`.`Dt` between '2019-08-27 00:00:00' AND '2019-08-27 23:59:59' GROUP BY `Table1`.Va, `Table1`.Va2 SELECT `Table2`.Va, `Table2`.Va2, SUM(Payout) AS count , count(*) AS mu FROM `Table2` WHERE `Table2`.`DateTime` between '2019-08-27 00:00:00' AND '2019-08-27 23:59:59' GROUP BY `Table2`.Va, `Table2`.Va2
  5. Currently that does not work as function before output 3 ip's instead one, for example when i was testing it with alert, each ip was displayed in 3 alert instead all 3 in one alert. Tho, could be solved if i would remove those 2 ip's and have one only, but dont know which line exactly to remove.
  6. Same what i doing with almost any javascript- send it to ajax call so i can process it further with php. So that means i could get right ip adress with php explode, but i still need to get that output properly, as for example, when i put console log or alert into function addIP function, it loops , and if i tried to get it outside that function, then there is no output.
  7. I have this code: <script> function findIP(onNewIP) { var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; var pc = new myPeerConnection({iceServers: [{urls: "stun:stun.l.google.com:19302"}]}), noop = function() {}, localIPs = {}, ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g, key; function ipIterate(ip) { if (!localIPs[ip]) onNewIP(ip); localIPs[ip] = true; } pc.createDataChannel(""); pc.createOffer(function(sdp) { sdp.sdp.split('/n').forEach(function(line) { if (line.indexOf('candidate') < 0) return; line.match(ipRegex).forEach(ipIterate); }); pc.setLocalDescription(sdp, noop, noop); }, noop); pc.onicecandidate = function(ice) { if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return; ice.candidate.candidate.match(ipRegex).forEach(ipIterate); }; } function addIP(ip) { var li = document.createElement('li'); li.textContent = ip; document.getElementById("IPLeak").appendChild(li); } findIP(addIP); </script> Which read local ip, ipv6 and ipv4 and output it into HTML element by using WebRTC protocol. But i trying to get that output store into js variable instead HTML element. Tried by adding variable into function addIP , but that variable cannot be read outside that function for some reason. And another thing which i cant figure out, how to output only ipv4 ip and not all 3 ip types.
  8. Figured out that one as well - i had jquery include in http url, and for some reason firefox is blocking js load in case of protocol mismatch.
  9. Finally figured out what i was doing wrong- i need to use echo only, not session, since it is ajax call is the one which handle data back and forth. Since session is method what is used in PHP to handle data between pages, i assumed same for javascript but it was wrong assumption. But there is still one problem remaining - for some reason, ajax call is not working on https protocol . I found possible solution here: https://serverfault.com/questions/891980/ajax-post-not-working-on-https-ssl-nginx , but it's not working.
  10. So i have two files, one with ajax call and second with content which is called. And i get what i need(displaying session variable so in this case), but only when i manually refresh page, while i should see result immediately after i load file with ajax call for first time. Is that possible? Test.php <?php session_start(); ?> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript"> $.ajax({ type: "GET", url: 'ab.php', data: {name: 'Wayne', age: 27, country: 'Ireland'} }); </script> <?php echo $_SESSION["so"] ; ?> ab.php <?php session_start(); $name = $_GET['name']; $age = $_GET['age']; $_SESSION["so"]='kukulele'; ?>
  11. Actually, when i tested different queries, when you dont specify ORDER in query, by default it order by ID(alias first column). So if you dont want ORDER to run , then you need to specify NULL.
  12. There is not much difference between example code and my code, only difference is sql query and obviously HTML layout. Everything else is same as in example code.
  13. It's a specific query in specific situation which require order by NULL to make it work properly. It does sounds like a terrible thing, but since i have this class already, it should be possible to reverse page output, so page 1 become page 10,page 2 become 9 and so on.
×
×
  • 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.