Jump to content

dodgeitorelse3

Members
  • Posts

    254
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by dodgeitorelse3

  1. What do you suppose your instructor would say if you went to him/her with same thing you posted here in your first post? And would you tell him/her you don't want their criticism just solutions?

    If you have written any code to attempt this simply post it as you should have done to begin with or at least when someone asked you for it. You didn't want to do that yet still want solutions.

    • Great Answer 1
  2. try this (untested)

    	// foreach loop to ping IP and check if alive or dead & dispaly result
        foreach ($systems as $ip) {
            unset($result);
            $successValue = "DOWN";
            exec("ping -n 1 $ip[ip]", $result);
            foreach($result as $line) {
                if (strpos($line,$good) == TRUE){
                    $successValue = "UP";
                }
            }
            //echo "<br><br>";
            echo "<table class='table'>
    				<tbody>
    					<tr>
    						<td>IP Address: ".$ip['ip']. "</td>
    						<tdUnit Name: ".$ip['name']."</td>
    					</tr>
    					<tr>>";
            
    			If ($successValue == "UP") {
    				 echo "<td>Status is: ".$successValue."</td>
    						<td><img src='/Images/GTick.jpg'></td>";
    		   }else{
    				echo "<td>Status is: ".$successValue."</td>
    						<td><img src='/Images/RTick.jpg'></td>";
    			}
    			
    			echo "</tr>
    				</tbody>
    			</table>";
        //debug dispaly full result of ping request
        //var_dump($result);
        }

     

  3. if I understand correctly this should work.

    echo "<div class='field-container'>";
    	
    	if($game['platform2'] !== ""){
    		echo "<div class='title'>Platform</div>    
    		<div class='information'>{$game['platform2']}</div>
    		<div class='title'>Launcher</div>    
    		<div class='information'>{$game['launcher2']}</div>";
    	}
    	
    echo "</div>";

     

  4. 5 hours ago, Sunnyisles said:

    I just need to echo class-variacion from this url https://mercados.ambito.com//dolar/informal/variacion

    This doesn't use your api but if page is always formatted that way then possibly
     

     <?php
    //DOLLAR//
        $json_dolar=file_get_contents("https://mercados.ambito.com//dolar/informal/variacion");
       
       $dolar=explode("\",", substr_replace(trim($json_dolar, '{}') ,"",-1));
            
    	echo trim(explode("\":\"", $dolar[4])[1])."<br><br>";
    	
    	foreach($dolar as $key => $value){
    		echo $value." OR ".trim(explode("\":\"", $dolar[$key])[1])."<br>";
    	}
    
    ?>

    Which displays

     

    up
    
    "compra":"202,50 OR 202,50
    "venta":"206,50 OR 206,50
    "fecha":"04\/01\/2022 - 16:45 OR 04\/01\/2022 - 16:45
    "variacion":"0,24% OR 0,24%
    "class-variacion":"up OR up

     

  5. I ended up with this however I suppose a php memory issue will arise when enough data is retrieved.

     

    	$all_data = array();				
    		foreach($id as $idkey => $iduse){
    			$temparr=array();
    				$result_time = $conn->query("SELECT * FROM ".$iduse." order by timedate Asc");
    					while ($rowtime = $result_time->fetch_row()) {
    						$temparr[] = $rowtime;
    					}
    						array_push($all_data, array("id" => $idonly[$idkey], "comment" => $comment[$idkey], "data" => $temparr));
    		}				
    			

    Also thank you Barand for the fetch_row replacement.

  6. Ok I am aware of the sins. The database I am using was created 18 years ago. The gsreaders database has a table labeled lgsl. This table houses all the details for each game server we track. There is an ID column for each server. Gsreaders database also has several other tables. 3 for each server. This is where the design issue comes into play. These tables have no columns in them to be able to use joins. The only way I know which 3 tables go to each server is by table name. So if for example a game server has ID 80 then the 3 corresponding tables use that I'd in the table name such as scoreboard_80_time. I am working on a page to allow users to look up data for a single server or all servers. This is why I get a list of all active servers and put the id's in an array. Then, for lack of knowledge I use another sin by running queries in the foreach. The globals were only there to see if it was an issue if not being able to pass data. Global will not be used. I used fetch row because each query result array must have the I'd of the server in final array so I know what data goes to which server as in the all_player_data array. Using fetch row as you suggested does not give me this.

    So my original question is still being asked. There are currently 20 active servers so there will be 20 all_player_data arrays. As each is made how do I push each to all_data array that is defined outside the foreach?

  7. I have a foreach statement that contains 20 values. with each value I run a query on tables to return results. I can get it to create an array but it only shows last foreach values returned results. How do I get all 20 results to be in $all_data array.

    my code so far is
     

    $all_data = array();			
    					
    		foreach($id as $idkey => $iduse){
    			global $all_data, $all_player_data, $temparr, $data;
    			$all_player_data = array();
    			$temparr = array();
    			
    				$result_time = $conn->query("SELECT * FROM ".$iduse." order by timedate Asc");
    				$temptdarray = array();
    				
    				while ($rowtime = $result_time->fetch_row()) {
    					$timedate   = $rowtime[0]; // row 0
    					$numplayers = $rowtime[1]; // row 1 
    					$maxplayers = $rowtime[2]; // row 2
    					$status     = $rowtime[3]; // row 3
    					$players    = $rowtime[4]; // row 4
    					$mapname    = $rowtime[5]; // row 5 
    					$maptype    = $rowtime[6]; // row 6 
    				
    					$data = array("timedate" => $timedate, "numplayers" => $numplayers, "maxplayers" => $maxplayers, "status" => $status, "players" => $players, "mapname" => $mapname, "maptype" => $maptype);
    					
    					array_push($temparr, $data);
    				}
    			$all_player_data[] = array("id" => $idonly[$idkey], "comment" => $comment[$idkey], "data" => $temparr);
    			array_push($all_data[], array($all_player_data));
    		}

    if I print_r($all_data) I get

    all_data
    Array
    (
        [0] => 
        [1] => 
        [2] => 
        [3] => 
        [4] => 
        [5] => 
        [6] => 
        [7] => 
        [8] => 
        [9] => 
        [10] => 
        [11] => 
        [12] => 
        [13] => 
        [14] => 
        [15] => 
        [16] => 
        [17] => 
        [18] => 
        [19] => 
    )

    if I print_r($all_player_data) I get
     

    all_player_data
    Array
    (
        [0] => Array
            (
                [id] => 80
                [comment] => FooFire Attack Team
                [data] => Array
                    (
                        [0] => Array
                            (
                                [timedate] => 2021-03-17 16:34
                                [numplayers] => 0
                                [maxplayers] => 10
                                [status] => 1
                                [players] => 
                                [mapname] => SF Village Coop
                                [maptype] => COOP
                            )
    
                        [1] => Array
                            (
                                [timedate] => 2021-03-20 07:12
                                [numplayers] => 1
                                [maxplayers] => 10
                                [status] => 1
                                [players] => --=P-51=--
                                [mapname] => SF Village Coop
                                [maptype] => COOP
                            )
    
                        [2] => Array
                            (
                                [timedate] => 2021-03-20 07:26
                                [numplayers] => 2
                                [maxplayers] => 10
                                [status] => 1
                                [players] => --=P-51=--, [FFAT]herbstfuerst
                                [mapname] => SF Village Coop
                                [maptype] => COOP
                            )
    
                        [3] => Array
                            (
                                [timedate] => 2021-03-20 07:28
                                [numplayers] => 3
                                [maxplayers] => 10
                                [status] => 1
                                [players] => --=P-51=--, [FFAT]herbstfuerst, YAKIR
                                [mapname] => SF Village Coop
                                [maptype] => COOP
                            )
    
    
    		.................blah blah blah
    
                    [7223] => Array
                            (
                                [timedate] => 2021-12-05 06:26
                                [numplayers] => 0
                                [maxplayers] => 10
                                [status] => 1
                                [players] => 
                                [mapname] => SF Village Coop
                                [maptype] => COOP
                            )
    
                        [7224] => Array
                            (
                                [timedate] => 2021-12-05 07:26
                                [numplayers] => 0
                                [maxplayers] => 10
                                [status] => 1
                                [players] => 
                                [mapname] => SF Village Coop
                                [maptype] => COOP
                            )
    
                        [7225] => Array
                            (
                                [timedate] => 2021-12-05 08:26
                                [numplayers] => 0
                                [maxplayers] => 10
                                [status] => 1
                                [players] => 
                                [mapname] => SF Village Coop
                                [maptype] => COOP
                            )
    
                    )
    
            )


    How do I get all 20 result sets into $all_data?

×
×
  • 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.