Jump to content

vivis933

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by vivis933

  1. thank you i have tried with google api but it doesent get the correct location , sow the wiki is my last option. I changed the code a bit but i get error. can you suggest any wikitext parser. Or to save as array the text eg. the | to be the separator of arrays and the = to divide key and value with the explode function or something else $url1 = "https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Broadwood_Stadium&rvsection=0"; $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $url1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_PROXYPORT, 3128); curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0); $response1 = curl_exec($ch1); curl_close($ch1); $response_a1 = json_decode($response1, true); $dist = $response_a1['query']['pages']; $dist2 = $response_a1['query']['pages'][$first_key]['revisions']; reset($dist); $first_key = key($dist); echo $first_key; print_r($dist2); $t = array_search("latd",$dist); echo $t; the echo of the firs key gives the correct number : 3750990.
  2. I need to extract data from this, i need latd , latm and lats. How to search the array and return the values ? result i need $latd = 55 $latm = 56 $lats = 41.19 $url1 = "https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Broadwood_Stadium&rvsection=0"; $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $url1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_PROXYPORT, 3128); curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0); $response1 = curl_exec($ch1); curl_close($ch1); $response_a1 = json_decode($response1, true); $dist = $response_a1['query']['pages']; print_r($dist) ;
  3. This an example of what i need , basically the variable from first function to be included in the second function. <?php $number1 = 6 ; $number2 = 4 ; $number3 = 2 ; funct1($number1, $number2); funct2($variable1 , $number3); echo $variable2; function funct1($number1, $number2) { $variable1 = $number1 + $number2 ; } function funct2($variable1 , $number3) { $variable2 = $variable1 / $number3 ; } ?> ERROR
  4. It is possible to make it like the example below ? function funct1($number1, $number2) { $variable1 = $number1 + $number2 ; } function funct2($variable1 , $number3) { $variable2 = $variable1 / $number3 ; }
  5. First code <?php include("conf.php"); $fixtures_data = mysqli_query($conn,"SELECT Location,Date,HomeTeam,AwayTeam FROM datagmaes"); if ($fixtures_data->num_rows > 0) { // output data of each row while($row = $fixtures_data->fetch_assoc()) { $team1 = $row["HomeTeam"]; $team2 = $row["AwayTeam"]; } } else { echo "0 results"; } ?> Second code <?php include("conf.php"); include("poi.php"); $home = mysqli_query($conn,"SELECT Teamdata1 FROM gamesdata WHERE Team='$team1'"); $row1 = $home->fetch_assoc(); $hometeam = number_format($row1['Teamdata1'],2); $away = mysqli_query($conn,"SELECT Teamdata2 FROM gamesdata WHERE Team='$team2'"); $row2 = $away->fetch_assoc(); $awayteam = number_format($row2['Teamdata2'],2); $calAll = array(); /////All calculations for($goals = 0 ; $goals <= 9 ; $goals++) { array_push($calAll, (poi($goals,$hometeam) * poi(0,$awayteam))*100, (poi($goals,$hometeam) * poi(1,$awayteam))*100, (poi($goals,$hometeam) * poi(2,$awayteam))*100, (poi($goals,$hometeam) * poi(3,$awayteam))*100, (poi($goals,$hometeam) * poi(4,$awayteam))*100, (poi($goals,$hometeam) * poi(5,$awayteam))*100, (poi($goals,$hometeam) * poi(6,$awayteam))*100, (poi($goals,$hometeam) * poi(7,$awayteam))*100, (poi($goals,$hometeam) * poi(8,$awayteam))*100, (poi($goals,$hometeam) * poi(9,$awayteam))*100 ); } $result1 = number_format(array_sum($calAll),2); echo $result1 . "\n"; ?> The first code return multiple items i need to apply the second code to every item in first code and then to save $result1 in mysql table. First code results if echo $team1," vs ",$team2; scgohometeam1 vs csgoawayteam1 scgohometeam2 vs csgoawayteam2 scgohometeam3 vs csgoawayteam3 scgohometeam4 vs csgoawayteam4 scgohometeam5 vs csgoawayteam5 scgohometeam6 vs csgoawayteam6 ... etc. Thes desired final echo after combinin the two codes Final code results if echo $team1," vs ",$team2," = ", $result1 ; scgohometeam1 vs csgoawayteam1 = 25 scgohometeam2 vs csgoawayteam2 = 45 scgohometeam3 vs csgoawayteam3 = 40 scgohometeam4 vs csgoawayteam4 = 30 scgohometeam5 vs csgoawayteam5 = 15 scgohometeam6 vs csgoawayteam6 = 23 ... etc.
  6. <?php function factorial($number) { if ($number < 2) { return 1; } else { return ($number * factorial($number-1)); } } function poisson($occurrence,$chance) { $e = exp(1); $a = pow($e, (-1 * $chance)); $b = pow($chance,$occurrence); $c = factorial($occurrence); return $a * $b / $c; } $x = 2.5; $y = 1.5; $calAll = array(); for($z = 0 ; $z <= 9 ; $z++) { array_push($calAll, (poisson($z,$x) * poisson(0,$y))*100, (poisson($z,$x) * poisson(1,$y))*100, (poisson($z,$x) * poisson(2,$y))*100 ); } $value = max($calAll); $key = array_search($value, $calAll); print_r($calAll) . "\n"; echo "max =",$value , " key =",$key . "\n";; ?> it is possible to find $z and the number 0,1 or 2 from the max of the returned array ? I used excel to perform this action and i found that for max=8.5854557290941 the $z is 2 and number 1 how to achieve this in php ?
  7. I tryed with this but i get 8 values insteed 7 <?php $e = array(); for($x= 0 , $x1= 0; $x<= 3 || $x1<= 2; $x++ , $x1++ ) { array_push($e, (poisson($x,2.5) * poisson(0,3.5))*100, (poisson($x1,2.5) * poisson(1,3.5))*100///<--second variable ); } //echo array_sum($e) . "\n"; print_r($e) . "\n"; ?>
  8. It is possible in the second variable the loop for x to go til 9 not 10 starting from 0 not -1 $e = array(); for($x= 0 ; $x<= 10 ; $x++) { array_push($e, (poisson($x,2.5) * poisson(0,3.5))*100, (poisson($x,2.5) * poisson(1,3.5))*100)///<--second variable ); } echo array_sum($e) . "\n"; i add $x-1 $e = array(); for($x= 0 ; $x<= 10 ; $x++) { array_push($e, (poisson($x,2.5) * poisson(0,3.5))*100, (poisson($x-1,2.5) * poisson(1,3.5))*100)///<--second variable ); } echo array_sum($e) . "\n";
  9. Thank you i fixed it $e = array(); for($x= 0 ; $x<= 10 ; $x++) { array_push($e, (poisson($x+1,2.5) * poisson(0,3.5))*100); } echo array_sum($e) . "\n";
  10. for($x= 0 ; $x<= 10 ; $x++) { $e = (poisson($x+1,2.5) * poisson(0,3.5))*100; echo $e . "\n"; } I make this code from the poisson distribution and ercho return this How i can get the sum of all those numbers? I tryed to make the variable to array and to use sum_array bur it doesent give the correct resul for($x= 0 ; $x<= 10 ; $x++) { $e = array((poisson($x+1,2.5) * poisson(0,3.5))*100); } echo array_sum($e) . "\n"; echo return 0.00014805309341072
  11. @jacques1 thank you i was using excel for the possession distribution and the formula is this POISSON.DIST(x,mean,cumulative) X Required. The number of events. Mean Required. The expected numeric value. Cumulative Required. A logical value that determines the form of the probability distribution returned. If cumulative is TRUE, POISSON.DIST returns the cumulative Poisson probability that the number of random events occurring will be between zero and x inclusive; if FALSE, it returns the Poisson probability mass function that the number of events occurring will be exactly x. Sow in the example you prepossessed can you tell me which values present the x, mean and cumulative.
  12. Thank you for the reply , I need the to integrate the r code in php to make possession distribution for some data in database(mysql) sow i was searching for it and im not satisfied with the results , when i tried to install this library i got to much errors . If some one have a suggestion how to make a possession distribution in php with or without an external library please help me.
  13. Hi i need THIS package to install on windows using composer but im new here can some one help me.
  14. When i run the code without UNION and with one SELECT it works but when i try to run all together it wont insert data into table, or to try in different way without UNION, some help here. <?php include("conf.php"); $query = "INSERT INTO fund(Team, GamesPlayedHome, GoalsScorredHome, GoalsAcceptedHome, RedCardGotHome, AvarageGoalsScorredHome, AvarageGoalsAcceptedHome, GamesPlayedAway, GoalsScorredAway, GoalsAcceptedAway, RedCardGotAway, AvarageGoalsScorredAway, AvarageGoalsAcceptedAway) SELECT HomeTeam As Team, COUNT(HomeTeam) AS GamesPlayedHome, SUM(HomeGoals) AS GoalsScorredHome, SUM(AwayGoals) AS GoalsAcceptedHome, SUM(HomeRedCards) AS RedCardGotHome, SUM(HomeGoals) / COUNT(HomeTeam) AS AvarageGoalsScorredHome, SUM(AwayGoals) / COUNT(HomeTeam) AS AvarageGoalsAcceptedHome FROM GetHistoricMatchesByLeagueAndDateInterval GROUP BY HomeTeam ORDER BY HomeTeam ASC UNION ALL SELECT COUNT(AwayTeam) AS GamesPlayedAway, SUM(AwayGoals) AS GoalsScorredAway, SUM(HomeGoals) AS GoalsAcceptedAway, SUM(AwayRedCards) AS RedCardGotAway, SUM(HomeGoals) / COUNT(AwayTeam) AS AvarageGoalsScorredAway, SUM(AwayGoals) / COUNT(AwayTeam) AS AvarageGoalsAcceptedAway FROM GetHistoricMatchesByLeagueAndDateInterval GROUP BY AwayTeam ORDER BY AwayTeam ASC"; $data= mysqli_query($conn,$query) or die(mysqli_error()); while($row = mysqli_fetch_assoc($data)){ foreach($row as $cname => $cvalue){ print "$cname: $cvalue\t"; } print "\r\n"; } ?>
  15. <?php include("conf.php"); $file_name = basename(__FILE__,'.php'); $table = $file_name; $query = "SELECT HomeTeam FROM " . $table; $result = mysqli_query($conn, $query); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } if (!mysqli_query($conn, "SET a=1")) { printf("Errormessage: %s\n", mysqli_error($conn)); } if(empty($result)) { echo "<p>" . $table . " table does not exist</p>"; $query = mysqli_query($conn,"CREATE TABLE IF NOT EXISTS $file_name ( HomeTeam int NOT NULL PRIMARY KEY, HomeGoals varchar(255) NOT NULL )CHARACTER SET utf8 COLLATE utf8_general_ci"); } else { echo "<p>" . $table . "table exists</p>"; } // else $sql = "INSERT INTO $file_name (HomeTeam, HomeGoals) VALUES ( SELECT HomeTeam, COUNT(HomeGoals) As HomeGoals FROM GetHistoricMatchesByLeagueAndDateInterval GROUP BY HomeTeam ORDER BY HomeTeam ASC )"; ?>
  16. no there is no error report when i run it i fixed the if(empty($resultat)) { with if(empty($result)) { data still not inserted, and no columns in table.
  17. I need both count and total but in the code i used only total for goals, i need this for further development. The table is created but the problem is in the INSERT INTO or SELECT can you help me do debug this.
  18. +------------+------------+ | HomeTeam | HomeGoals | +------------+------------+ | Team1 | 2 | +------------+------------+ | Team3 | 5 | +------------+------------+ | Team1 | 2 | +------------+------------+ | Team2 | 3 | +------------+------------+ | Team2 | 2 | +------------+------------+ | Team3 | 2 | +------------+------------+ | Team1 | 2 | +------------+------------+ I need the following results Number of times the team is on column Team1 = 3 times Team2 = 2 times Team3 = 2 times And the total number of goals the time has Team1 = 6 goals Team2 = 5 goals Team3 = 7 goals And inserting it in new table
  19. Hi i made this code but when i run there is no data in the table <?php include("conf.php"); $file_name = basename(__FILE__,'.php'); $table = $file_name; $query = "SELECT HomeTeam FROM " . $table; $result = mysqli_query($conn, $query); if(empty($resultat)) { echo "<p>" . $table . " table does not exist</p>"; $query = mysqli_query($conn,"CREATE TABLE IF NOT EXISTS $file_name ( HomeTeam int NOT NULL PRIMARY KEY, HomeGoals varchar(255) NOT NULL )CHARACTER SET utf8 COLLATE utf8_general_ci"); } else { echo "<p>" . $table . "table exists</p>"; } // else $sql = "INSERT INTO $file_name (HomeTeam, HomeGoals) VALUES ( SELECT HomeTeam, COUNT(HomeGoals) As HomeGoals FROM GetHistoricMatchesByLeagueAndDateInterval GROUP BY HomeTeam ORDER BY HomeTeam ASC )"; ?>
  20. oh i didn't see that but now i get this error
  21. Thnx for the replay I changed the code and included your statement in it but it gives to me an error <?php include("XMLSoccer.php"); include ("conf.php"); $file_name = basename(__FILE__,'.php'); try{ $soccer=new XMLSoccer($api_key); $soccer->setServiceUrl("http://www.xmlsoccer.com/FootballDataDemo.asmx"); $result=$soccer->GetAllLeagues(); print_r($result); } catch(XMLSoccerException $e){ echo "XMLSoccerException: ".$e->getMessage(); } $table = $file_name; $query = "SELECT ID FROM " . $table; $result = mysqli_query($conn,$query); if(empty($result)) { echo "<p>" . $table . " table does not exist</p>"; $query = mysqli_query($conn,"CREATE TABLE IF NOT EXISTS $file_name ( Id VARCHAR(300), Name VARCHAR(300), Country VARCHAR(30), Historical_Data VARCHAR(300), Fixtures VARCHAR(300), Livescore VARCHAR(300), NumberOfMatches VARCHAR(30), LatestMatch VARCHAR(300), IsCup VARCHAR(300) )"); } else { echo "<p>" . $table . "table exists</p>"; } // else foreach ($results->League as $team) { $leagueid = $team->Id; $name = $team->Name; $country = $team->Country; $historical_Data = $team->Historical_Data; $fixtures = $team->Fixtures; $livescore = $team->Livescore; $numberOfMatches = $team->NumberOfMatches; $latestMatch = $team->LatestMatch; $isCup = $team->IsCup; } ?> THE ERROR
  22. I need to save the data in mysql into rows and colums. pls some help The colums to be like Team , Team id , played etc <?php class XMLSoccer{ protected $service_url="http://www.xmlsoccer.com/FootballData.asmx"; protected $api_key,$request_ip; const TIMEOUT_GetLiveScore=25; const TIMEOUT_GetLiveScoreByLeague=25; const TIMEOUT_GetOddsByFixtureMatchID=3600; const TIMEOUT_GetHistoricMatchesByLeagueAndSeason=3600; const TIMEOUT_GetAllTeams=3600; const TIMEOUT_GetAllTeamsByLeagueAndSeason=3600; const TIMEOUT_Others=300; const TIMEOUT_CURL=30; public function __construct($api_key=""){ $this->request_ip=gethostbyname(gethostname()); if(empty($this->service_url)) throw new XMLSoccerException("service_url cannot be empty. Please setup"); if(!empty($api_key)) $this->api_key=$api_key; if(empty($this->api_key)) throw new XMLSoccerException("api_key cannot be empty. Please setup."); } /* list available methods with params. */ public function __call($name,$params){ $data=$this->request($this->buildUrl($name,$params)); if(false===($xml = simplexml_load_string($data))) throw new XMLSoccerException("Invalid XML"); if(strstr($xml[0],"To avoid misuse of the service")){ switch($name){ case "GetLiveScore": case "GetLiveScoreByLeague": case "GetOddsByFixtureMatchID": case "GetHistoricMatchesByLeagueAndSeason": case "GetAllTeams": case "GetAllTeamsByLeagueAndSeason": throw new XMLSoccerException($xml[0],constant("self::TIMEOUT_".$name)); default: throw new XMLSoccerException($xml[0],self::TIMEOUT_Others); } } return $xml; } protected function buildUrl($method,$params){ $url=$this->service_url."/".$method."?apikey=".$this->api_key; for($i=0;$i<count($params);$i++){ if(is_array($params[$i])){ foreach($params[$i] as $key=>$value){ $url.="&".strtolower($key)."=".rawurlencode($value); } } else{ throw new XMLSoccerException("Arguments must be an array"); } } return $url; } protected function request($url){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, self::TIMEOUT_CURL); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, self::TIMEOUT_CURL); curl_setopt($curl, CURLOPT_INTERFACE,$this->request_ip); $data = curl_exec($curl); $cerror=curl_error($curl); $cerrno=curl_errno($curl); $http_code=curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if($cerrno!=0) throw new XMLSoccerException($cerror,E_USER_WARNING); if($http_code == 200 ) return $data; throw new XMLSoccerException($http_code .' - '. $data . "\nURL: " . $url); } public function setRequestIp($ip){ if(empty($ip)) throw new XMLSoccerException("IP parameter cannot be empty",E_USER_WARNING); $this->request_ip=$ip; } public function setServiceUrl($service_url){ if(empty($service_url)) throw new XMLSoccerException("service_url parameter cannot be empty",E_USER_WARNING); $this->service_url=$service_url; } } class XMLSoccerException extends Exception{ } try{ $soccer=new XMLSoccer("your_key"); $soccer->setServiceUrl("http://www.xmlsoccer.com/FootballDataDemo.asmx"); $result=$soccer->GetLeagueStandingsBySeason(array("league"=>3,"seasonDateString"=>"1314")); print_r($result); } catch(XMLSoccerException $e){ echo "XMLSoccerException: ".$e->getMessage(); } ?> The result is this
×
×
  • 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.