Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. ...
  2.  
  3. $titles = $html->find("a[class=in-match]"); // 1 per match
  4. $result = $html->find("td[class=h-text-center]/a"); // 1
  5. $best_bets = $html->find("td[class=table-matches__odds colored]/span/span/span"); // 1
  6. $odds = $html->find("td[class=table-matches__odds]"); // 2
  7.  
  8. function print_odd($odd) {
  9. if (array_key_exists('data-odd', $odd->attr)) {
  10. return $odd->attr['data-odd'];
  11. }
  12.  
  13. return $odd->children(0)->children(0)->children(0)->attr['data-odd'];
  14. }
  15.  
  16.  
  17. $c=0; $b=0; $o=0; $z=0; // two counters
  18. foreach ($titles as $match) {
  19. list($num1, $num2) = explode(':', $result[$c++]->innertext); // <- explode
  20. $num1 = intval($num1);
  21. $num2 = intval($num2);
  22. $num3 = ($num1 + $num2);
  23. if ($num3 > 1){
  24.  
  25. $over15 = "OK";
  26. }else {
  27.  
  28. $over15 = "NO";
  29. }
  30.  
  31.  
  32. echo "<tr><td class='rtitle'>".
  33.  
  34. "<td class='first-cell'>".$match->innertext."</td> " .
  35.  
  36.  
  37.  
  38.  
  39. "<td>".$match->innertext."</td><td> ".$num1.'</td><td> : </td><td>'.$num2 . " / " . // <- example use
  40. "<td class='first-cell'>".$num3 ."</td> " .
  41. "<td class='first-cell'>".$over15 ."</td> " .
  42. "<td class='odds'>".print_odd($odds[$b++]) . ";" .
  43. "".print_odd($odds[$b++]) . ";" .
  44. "".print_odd($odds[$b++]) . "</td>" .
  45. "</td></tr><br/>";
  46.  
  47.  
  48. $servername = "xx.xxx.xxx.xxx";
  49. $username = "xxx";
  50. $password = "xxx";
  51. $dbname = "xxxxxxxx";
  52.  
  53. // Create connection
  54. $conn = new mysqli($servername, $username, $password, $dbname);
  55. // Check connection
  56. if ($conn->connect_error) {
  57. die("Connection failed: " . $conn->connect_error);
  58. }
  59.  
  60. $sql = "INSERT INTO risultati (titles, scorehome, scoreaway, best_bets)
  61. VALUES ('$match', '$num1', '$num2', '$odds');";
  62.  
  63.  
  64. if ($conn->multi_query($sql) === TRUE) {
  65. echo "New records created successfully";
  66. } else {
  67. echo "Error: " . $sql . "<br>" . $conn->error;
  68. }
  69.  
  70. $conn->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement