stuk "afkappen" van gestripte tabel

Status
Niet open voor verdere reacties.

Sennec

Gebruiker
Lid geworden
17 jan 2009
Berichten
77
Ik heb een tabel gestript (http://limburg.basketbalvlaanderen.org/kalweekclub.asp?club=1665) die ik zou willen weergeven met een andere lay-out.Maar er is een klein javascriptje dat ik niet zomaar wegkrijg, kan iemand mij helpen ?

Dit is de tabel mét het javascriptje onderaan de pagina:

HTML:
<table width="630" border="0" align="center" cellspacing="0" cellpadding="3">
	<tr><th colspan="6"><a href="kalweekclub.asp?v=0&club=1665&week=21/08/2009&css=0"><img src="driehoek_rood2.gif" width="5" height="9" border="0" alt="vorige"></a>
		 
		  Wedstrijden in weekend van 29 en 30&nbsp;augustus
		<a href="kalweekclub.asp?v=0&club=1665&week=4/09/2009&css=0"><img src="driehoek_rood.gif" width="5" height="9" border="0" alt="volgende"></a>	</th>
		</tr>
 
		<tr><td width="130">
		&nbsp;<a href="kalploeg.asp?v=0&ploeg=16653011&css=0">Heren A</a>
		</td>
	    <td align="right">
			90101&nbsp;
		</td>
			<td width="310" nowrap>Turuka Willebroek B&nbsp;-&nbsp;Nieuwerkerken A
					<span class="beker">&nbsp;(BvV)</span>
				
                
			</td>
			<td width="70" align="center" nowrap="nowrap">-</td>
			<td width="20" align="right">za</td>
			<td width="50" align="center">
			18:30
			</td>
			</tr>
			
		<tr class=even><td width="130">
		&nbsp;<a href="kalploeg.asp?v=0&ploeg=16653012&css=0">Heren B</a>
		</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
		<tr><td width="130">
		&nbsp;<a href="kalploeg.asp?v=0&ploeg=16653021&css=0">Prov. Juniors</a>
		</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
		<tr class=even><td width="130">
		&nbsp;<a href="kalploeg.asp?v=0&ploeg=16653041&css=0">Prov. Miniemen</a>
		</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
		<tr><td width="130">
		&nbsp;<a href="kalploeg.asp?v=0&ploeg=16653051&css=0">Prov. Pupillen</a>
		</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
		<tr class=even><td width="130">
		&nbsp;<a href="kalploeg.asp?v=0&ploeg=16653061&css=0">Benjamins A</a>
		</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
		<tr><td width="130">
		&nbsp;<a href="kalploeg.asp?v=0&ploeg=16653062&css=0">Benjamins B</a>
		</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
		<tr class=even><td width="130">
		&nbsp;<a href="kalploeg.asp?v=0&ploeg=16653211&css=0">Microben</a>
		</td>
	    <td align="right">
			&nbsp;
		</td>
			<td width="310" nowrap>Basket Lummen&nbsp;-&nbsp;Nieuwerkerken
					<span class="beker">&nbsp;(oefen)</span>
				
                
			</td>
			<td width="70" align="center" nowrap="nowrap">-</td>
			<td width="20" align="right">zo</td>
			<td width="50" align="center">
			09:00
			</td>
			</tr>
			
</table>
</p>
<p align="center">
<script language="JavaScript"><!-- Begin
if (window.print) {
document.write('<form>'
+ '<input type=button name=print value="Afdrukken" '
+ 'onClick="javascript:window.print()"></form>');
}
// End -->
</script>
 
</p>
<script type="text/javascript"> 
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript"> 
var pageTracker = _gat._getTracker("UA-5769703-4");
pageTracker._trackPageview();
</script>


En dit is mijn code waarmee ik de tabel uit de externe pagina ophaal en er een andere layout aan geef, alleen kan ik met str_replace het script niet verwijderen.

PHP:
echo'<table border="0" rules="rows"> 
	<tr style="border: 1px solid #D8D8D8; background-color:#F0F0F0;"><th colspan="6" align="center">Deze week</th></tr><tr>';
				$bestand = file_get_contents("http://limburg.basketbalvlaanderen.org/kalweekclub.asp?club=1665");
					if ($bestand != FALSE) {
						//vind startstuk en neem alles erna
						$tabel = stristr($bestand, '<td');
						if ($tabel == FALSE) {
							echo '<p>Er is geen klassement beschikbaar.</p>';
						} else {
							
							$pos = strripos($tabel, '</table>');
							if ($pos === FALSE) {
								$tabel = FALSE;
							} else {
								$tabel = str_replace('kalploeg.asp', 'http://limburg.basketbalvlaanderen.org/kalploeg.asp', $tabel);
								$tabel = str_replace('<a', '<a target="_blank"', $tabel);
								
						


							} 
							
        
							if ($tabel == FALSE) {
								echo '<p>Tabel onvolledig</p>';
							} else {
								echo ' <tr>';
								echo $tabel;
							}
						}
					} else {
						echo '<p>Klassement kon niet worden ingelezen.</p>';
			}

Ik zoek dus eigenlijk een manier, om mijn tabel te strippen vanaf <table> en direct ook te stoppen na </table> en niet gewoon de hele pagina te nemen na <table>
 
Als je onderstaande substr() op regel 17 zet wordt alles na </table> gewist:
PHP:
$tabel = substr($tabel,0,($pos+8));
 
Of zo:

PHP:
<?php

	$aFile = file ( 'http://limburg.basketbalvlaanderen.org/kalweekclub.asp?club=1665' );
	$iLines = count ( $aFile );
	$iStart = 0;
	$iEnd = $iLines - 1;
	
	function absoluteLinks ( $aInput ) {
		
		foreach ( $aInput as $key => $sLine ) {
			
			$sLine = str_replace ( 'kalploeg.asp', 'http://limburg.basketbalvlaanderen.org/kalploeg.asp', $sLine );
			$sLine = str_replace ( '<a', '<a target="_blank"', $sLine );
			$aInput[$key] = $sLine;
			
		}
		
		return $aInput;
		
	}
	
	
	foreach ( $aFile as $key => $value ) {
		
		if ( $iStart == 0 && stripos ( $value, '<table' ) !== false ) {
			$iStart = $key + 6;
		}
		
		if ( $iEnd == ($iLines - 1) && stripos ( $value, '</table>' ) !== false ) {
			$iEnd = $key;
		}
		
	}
	
	$aFile = array_slice ( $aFile, $iStart, $iEnd - $iStart + 1 );
	
	$aFile = absoluteLinks ( $aFile );
	
	echo'<table border="0" rules="rows"> 
    <tr style="border: 1px solid #D8D8D8; background-color:#F0F0F0;"><th colspan="6" align="center">Deze week</th></tr><tr>';
	foreach ( $aFile as $sLine ) {
		echo $sLine, "\r\n";
	}

?>

(Alleen nog even je styling toevoegen).
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan