Autor | Zpráva | ||
---|---|---|---|
dawe27 Profil |
#1 · Zasláno: 21. 2. 2013, 15:33:10
Zdravím, parsoval jsem si tabulku tímto scriptem, ale potřeboval bych poradit jak vypustit některé sloupce, ví někdo jak na to? neporadili by jste mi prosím?
<?php header("content-type: text/html; charset=utf-8"); // vysledky $data = getData('http://www.cfbu.cz/fis_proxy.php?request=fisexternal&ajax=1&division_code=B&competition_code=7XW32012/2013&ajaxtask=reports&reportno=3&antiCache=1361455204127&elementid=vystup1&targetdiv=true&async=true'); echo $data; //<table class="competitiontable"> function getData($url = '', $ttl = 3600) { // vychozi priznak $cached = true; // nenalezen soubor nebo probehl expiraci if (!is_file("./cache/" . md5($url)) || time() - filemtime("./cache/" . md5($url)) > $ttl) $cached = false; // neni kesovano if (!$cached) { // debug //echo "znovu parsujeme tabulku - " . date('d.m.Y H:i:s'); $f = file_get_contents($url); //$f = iconv("WINDOWS-1250", "UTF-8", $f); if (!$f) { echo 'Nelze načíst - ' . $url ; return; } // ulozime file_put_contents("./cache/".md5($url), $f); } // nacteme tabulku $table = file_get_contents("./cache/".md5($url)); $tr = file_get_contents("./cache/".md5($url)); preg_match('~<table class="competitiontable">(.+?)</table>~s', $table, $out); $html = '<table border="0" class="tabulkapanelzeny" cellpadding="0" cellspacing="0" >'.$out[1].'</table>'; $html = preg_replace("/\<a(.*)\>(.*)\<\/a\>/iU", "$2", $html); return $html; } ?> |
||
dawe27 Profil |
#2 · Zasláno: 21. 2. 2013, 23:32:16
povedlo se mi to vyřešit ale když chci mít na 1 stránce více tabulek vypiše mi to chybu (rozbalovací panel) a rozhází web
http://testweb.hys.cz/6/table.php?tabulka=zeny neví někdo co dělám špatně? Na hlavní stránce funguje bez problému ale když najedu na stránku kde je těch tabulek více objeví se tam ten error table.php <?php require_once "settings.php"; ob_start(); if($_GET["tabulka"] == zeny ){ require_once "table1.php"; echo $data; } $obsah= ob_get_clean(); require_once "theme.php"; ?> </body> </html> <? ?> table1.php <?php header("content-type: text/html; charset=utf-8"); // vysledky $data = getData('http://www.cfbu.cz/fis_proxy.php?request=fisexternal&ajax=1&division_code=B&competition_code=7XW32012/2013&ajaxtask=reports&reportno=3&antiCache=1361455204127&elementid=vystup1&targetdiv=true&async=true'); //<table class="competitiontable"> function getData($url = '', $ttl = 3600) { // vychozi priznak $cached = true; // nenalezen soubor nebo probehl expiraci if (!is_file("./cache/" . md5($url)) || time() - filemtime("./cache/" . md5($url)) > $ttl) $cached = false; // neni kesovano if (!$cached) { // debug //echo "znovu parsujeme tabulku - " . date('d.m.Y H:i:s'); $f = file_get_contents($url); //$f = iconv("WINDOWS-1250", "UTF-8", $f); if (!$f) { echo 'Nelze načíst - ' . $url ; return; } // ulozime file_put_contents("./cache/".md5($url), $f); } // nacteme tabulku $table = file_get_contents("./cache/".md5($url)); preg_match('~<table class="competitiontable">(.+?)</table>~s', $table, $out); $html = '<table border="1" cellpadding="0" cellspacing="0" >'.$out[1].'</table>'; //$html = preg_replace("/\<a(.*)\>(.*)\<\/a\>/iU", "$2", $html); // odstrani odkazy return $html; } ?> tabulkazeny.php <?php header("content-type: text/html; charset=utf-8"); include 'simple_html_dom.php'; ob_start(); include ("panels/tabulkapanelzeny.php"); $table= ob_get_clean(); $html = str_get_html($table); $data = array(); $rows = $html->find("tr"); $r = 0; foreach ($rows as $tr) { $td = $tr->find("td"); $th = $tr->find("th"); $i = 0; foreach ($td as $cell) { // chci jen prvni 2 bunky / sloupecky if ($i == 0 || $i == 1 || $i == 3 || $i == 6 || $i == 9) { $data[$r][$i] = $cell->plaintext; } $i++; } $r++; } echo '<table border="0" cellpadding="0" cellspacing="2" align="center" width"325" class="tabulkapanelzeny">'; echo "<tr class='th1'><th>#</th><th>Tým</th><th>Z</th><th>B</th><th>+/-</th></tr>"; foreach ($data as $rowIndex => $row) { echo "<tr class='td1'>"; foreach ($row as $cellIndex => $cell) { echo "<td>".$data[$rowIndex][$cellIndex]."</td>"; } echo "</tr>"; } echo "</table>"; tabulkapanelzeny.php <?php header("content-type: text/html; charset=utf-8"); // vysledky $data = getData('http://www.cfbu.cz/fis_proxy.php?request=fisexternal&ajax=1&division_code=B&competition_code=7XW32012/2013&ajaxtask=reports&reportno=3&antiCache=1361455204127&elementid=vystup1&targetdiv=true&async=true'); echo $data; //<table class="competitiontable"> function getData($url = '', $ttl = 3600) { // vychozi priznak $cached = true; // nenalezen soubor nebo probehl expiraci if (!is_file("./cache/" . md5($url)) || time() - filemtime("./cache/" . md5($url)) > $ttl) $cached = false; // neni kesovano if (!$cached) { // debug //echo "znovu parsujeme tabulku - " . date('d.m.Y H:i:s'); $f = file_get_contents($url); //$f = iconv("WINDOWS-1250", "UTF-8", $f); if (!$f) { echo 'Nelze načíst - ' . $url ; return; } // ulozime file_put_contents("./cache/".md5($url), $f); } // nacteme tabulku $table = file_get_contents("./cache/".md5($url)); $tr = file_get_contents("./cache/".md5($url)); preg_match('~<table class="competitiontable">(.+?)</table>~s', $table, $out); $html = '<table border="0" class="tabulkapanelzeny" cellpadding="0" cellspacing="5" >'.$out[1].'</table>'; $html = preg_replace("/\<a(.*)\>(.*)\<\/a\>/iU", "$2", $html); return $html; } ?> |
||
Kcko Profil |
#3 · Zasláno: 23. 2. 2013, 10:09:06
Vždy ti to píše hlášku Fatal error: require_once(): Failed opening required 'panels/tabulkapanelzeny'
špatný include. |
||
dawe27 Profil |
#4 · Zasláno: 23. 2. 2013, 11:27:46
JJ , to mi piše teďkom, už jsem změnil názvy souboru, ale psalo to jinou chybu
Fatal error: Cannot redeclare getdata() in /home/users/dawe27/testweb.hys.cz/web/6/panels/tabulkapanelzeny.php on line 16 |
||
Kcko Profil |
#5 · Zasláno: 23. 2. 2013, 12:19:33
dawe27:
Tu funkci umísti do nějakého globálního souboru funkcí, nemůžeš mít tu samou funkci několikrát nadefinovanou. Upřímně, doporučuji si přečíst základy PHP. |
||
dawe27 Profil |
#6 · Zasláno: 23. 2. 2013, 20:39:08
skusil jsem to takto, už to funguje o něco lépe, tabulka se zobrazi, ale je tam pořad ta chyba
http://testweb.hys.cz/6/table.php?tabulka=zeny settings.php <?php $server = ""; $login = ""; $heslo = ""; $databaze = ""; MySQL_Connect($server, $login, $heslo) or die("Nepodařilo se připojit k databázi"); MySQL_Select_DB($databaze) or die("Nepodařilo se otevřít databázi"); $con = mysql_connect($server, $login, $heslo); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($databaze, $con); foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); $prihlasen = $_SESSION['login']; function getData($url = '', $ttl = 3600) { // vychozi priznak $cached = true; // nenalezen soubor nebo probehl expiraci if (!is_file("./cache/" . md5($url)) || time() - filemtime("./cache/" . md5($url)) > $ttl) $cached = false; // neni kesovano if (!$cached) { // debug //echo "znovu parsujeme tabulku - " . date('d.m.Y H:i:s'); $f = file_get_contents($url); //$f = iconv("WINDOWS-1250", "UTF-8", $f); if (!$f) { echo 'Nelze načíst - ' . $url ; return; } // ulozime file_put_contents("./cache/".md5($url), $f); } // nacteme tabulku $table = file_get_contents("./cache/".md5($url)); $tr = file_get_contents("./cache/".md5($url)); preg_match('~<table class="competitiontable">(.+?)</table>~s', $table, $out); $html = '<table border="0" class="tabulkapanelzeny2" cellpadding="0" cellspacing="1" >'.$out[1].'</table>'; $html = preg_replace("/\<a(.*)\>(.*)\<\/a\>/iU", "$2", $html); return $html; } ?> tabulkapanelzeny.php <?php $data = getData('http://www.cfbu.cz/fis_proxy.php?request=fisexternal&ajax=1&division_code=B&competition_code=7XW32012/2013&ajaxtask=reports&reportno=3&antiCache=1361455204127&elementid=vystup1&targetdiv=true&async=true'); echo $data; ?> tabulkazeny.php je stejné jak v předchozím příspěvků |
||
dawe27 Profil |
#7 · Zasláno: 24. 2. 2013, 23:07:52
tak už se mi to povedlo vyřešit, dik
|
||
Časová prodleva: 12 měsíců
|
|||
Robomysicka Profil * |
#8 · Zasláno: 12. 2. 2014, 19:25:25
Zdravím,
potřeboval bych radu. Snažím se o něco podobného, ale z webu http://vysledky.lidovky.cz/soutez.php?sport=1&stat=107&kraj=9&okres=69&vek=1&typ=1 Nemůžete mi někdo poradit? Tedy potřebuju vložit tabulku z této stránky na svůj web. |
||
Časová prodleva: 10 let
|
0