nieuwsscript

Status
Niet open voor verdere reacties.

whitetigerck

Gebruiker
Lid geworden
8 aug 2008
Berichten
196
ik heb het volgende script gevonden:



PHP:
<?php 

$BAS2 = "3";

//Aantal nieuwsitems in totaal, als er één nieuwsitem bijkomt moet u deze waarde met één verhogen

/*Als u een nieuw nieuwsitem wil toevoegen moet u de twee regels hieronder kopiëren en dan hier plaatsen. En dan moet u het bestand in de bovenste regel in dit geval "./nieuwsins/1113.txt" vervangen door het nieuwe bestand met het nieuwsitem er in in dit geval "./nieuwsins/1114.txt" dus. Ook moet u de waardes allemaal met één verhogen en de waarde van de variabele $BAS2 ook. */

$GNP11[2] = fopen("./nieuwsins/1003.txt","r"); 
$GNP12[2] = fgets($GNP11[2],2555);

/*Haal de gegevens op uit het bestand "1113.txt", in dit bestand moet het nieuwsitem staan. Alle waardes zijn "2" dat is dus één minder als de waarde van de variabele "BAS2" */

$GNP11[1] = fopen("./nieuwsins/1002.txt","r"); 
$GNP12[1] = fgets($GNP11[1],2555);

$GNP11[0] = fopen("./nieuwsins/1001.txt","r"); 
$GNP12[0] = fgets($GNP11[0],2555);

?></font>


<?php
function navigatie($currentpage,$totalpages,$url)
{
$output = '';
$output_num = '';

// both = 4 of meer
if (($currentpage - 4) > 0 && ($currentpage + 4) < $totalpages) {
for($a = ($currentpage-4);$a <= ($currentpage+4);$a++) {
if ($a == $currentpage) {
$output_num .= ' <b>[' . $a .']</b> ';
} else {
$output_num .= ' <a href="' . $url . $a . '">' . $a . '</a> ';
}
}
if (($currentpage - 4) == 1) {
$first = false;
} else {
$first = true;
}
if (($currentpage + 4) == $totalpages) {
$last = false;
} else {
$last = true;
}

// left = 4 of meer
} elseif (($currentpage - 4) > 0) {
$math = $totalpages - $currentpage;
$start_temp = 9 - $math;
$start = $currentpage - $start_temp;
if ($start < 1) {
$start = 1;
}
for($a = $start;$a <= $totalpages;$a++) {
if ($a == $currentpage) {
$output_num .= ' <b>[' . $a .']</b> ';
} else {
$output_num .= ' <a href="' . $url . $a . '">' . $a . '</a> ';
}
}
$last = false;
$first = true;
// right = 4 of meer
} elseif (($currentpage + 4) < $totalpages) {
if ($totalpages > 9) {
$loop = 9;
} else {
$loop = $totalpages;
}
for($a = 1;$a <= $loop;$a++) {
if ($a == $currentpage) {
$output_num .= ' <b>[' . $a .']</b> ';
} else {
$output_num .= ' <a href="' . $url . $a . '">' . $a . '</a> ';
}
}
$last = true;
$first = false;
// none = 4 of meer
} else {
for($a = 1;$a <= $totalpages;$a++) {
if ($a == $currentpage) {
$output_num .= ' <b>[' . $a .']</b> ';
} else {
$output_num .= ' <a href="' . $url . $a . '">' . $a . '</a> ';
}
}
$last = false;
$first = false;
}
if ($first == true) {
$output .= ' <b><a href="' . $url . '1">[eerste]</a></b> '; 
}
if ($currentpage != 1) { 
$output .= ' <b><a href="' . $url . ($currentpage-1) .' ">[vorige]</a></b> '; 

}
$output .= " &nbsp;&nbsp; " . $output_num . "&nbsp;&nbsp;";
if ($currentpage != $totalpages) {
$output .= ' <b><a href="' . $url . ($currentpage+1) . ' ">[volgende]</a></b> '; 
}
if ($last == true) {
$output .= '<b><a href="' . $url . $totalpages . ' ">[laatste]</a></b> '; 
}

return $output;
}
?>

<?php
$PBS1 = $BAS2 / 9;
$PBS2 = round($PBS1);

$itemsperpage = 30;
$totalrecords = 60; // dit kan een aantal records zijn uit de database
$totalpages = ceil($PBS2);
if (!IsSet($_GET['p'])) {
$currentpage = 1;
} else {
$currentpage = ceil($_GET['p']);
}
if ($currentpage < 1 || $currentpage > ceil($totalpages)) {
$output = 'Helaas, deze pagina bestaat niet.';
} else {
$output = navigatie($currentpage,$totalpages,'?p=');
$output .= '<br /><br />Pagina: ' . $currentpage;
}

$W11 = $BAS2 - 1;
$W12 = $BAS2 - 2;
$W13 = $BAS2 - 3;
$W14 = $BAS2 - 4;
$W15 = $BAS2 - 5;
$W16 = $BAS2 - 6;
$W17 = $BAS2 - 7;
$W18 = $BAS2 - 8;
$W19 = $BAS2 - 9;
$W20 = $BAS2 - 10;
$W21 = $BAS2 - 11;
$W22 = $BAS2 - 12;
$W23 = $BAS2 - 13;
$W24 = $BAS2 - 14;
$W25 = $BAS2 - 15;
$W26 = $BAS2 - 16;
$W27 = $BAS2 - 18;
$W28 = $BAS2 - 17;
$W29 = $BAS2 - 19;
$W30 = $BAS2 - 20;
$W31 = $BAS2 - 21;
$W32 = $BAS2 - 22;
$W33 = $BAS2 - 23;
$W34 = $BAS2 - 24;
$W35 = $BAS2 - 25;
$W36 = $BAS2 - 26;
$W37 = $BAS2 - 27;
$W38 = $BAS2 - 28;
$W39 = $BAS2 - 29;
$W40 = $BAS2 - 30;
$W41 = $BAS2 - 31;
$W42 = $BAS2 - 32;
$W43 = $BAS2 - 33;
$W44 = $BAS2 - 34;
$W45 = $BAS2 - 35;
$W46 = $BAS2 - 36;
$W47 = $BAS2 - 37;
$W48 = $BAS2 - 38;
$W49 = $BAS2 - 39;
$W50 = $BAS2 - 40;
$W51 = $BAS2 - 41;
$W51 = $BAS2 - 42;
$W52 = $BAS2 - 43;
$W53 = $BAS2 - 44;
$W54 = $BAS2 - 45;
$W55 = $BAS2 - 46;
$W56 = $BAS2 - 47;
$W57 = $BAS2 - 48;
$W58 = $BAS2 - 48;
$W59 = $BAS2 - 49;
$W60 = $BAS2 - 50;
$W61 = $BAS2 - 51;
$W62 = $BAS2 - 52;
$W63 = $BAS2 - 53;
$W64 = $BAS2 - 54;
$W65 = $BAS2 - 55;
$W66 = $BAS2 - 56;
$W67 = $BAS2 - 57;
$W68 = $BAS2 - 58;
$W69 = $BAS2 - 59;
$W70 = $BAS2 - 60;
$W71 = $BAS2 - 61;
$W72 = $BAS2 - 62;
$W73 = $BAS2 - 63;
$W74 = $BAS2 - 64;
$W75 = $BAS2 - 65;
$W76 = $BAS2 - 66;
$W77 = $BAS2 - 67;
$W78 = $BAS2 - 68;
$W78 = $BAS2 - 69;
$W80 = $BAS2 - 70;

if($currentpage == '1'){
print "
<p>
$GNP12[$W11]
$GNP12[$W12]
$GNP12[$W13]
$GNP12[$W14]
$GNP12[$W15]
$GNP12[$W16]
$GNP12[$W17]
$GNP12[$W18]
$GNP12[$W19]
$GNP12[$W20]
$GNP12[$W21]
$GNP12[$W22]
$GNP12[$W23]
$GNP12[$W24]
$GNP12[$W25]
</p>

";
}

if($currentpage == '2'){
print "
<p>
$GNP12[$W26]
$GNP12[$W27]
$GNP12[$W28]
$GNP12[$W29]
$GNP12[$W30]
$GNP12[$W31]
$GNP12[$W32]
$GNP12[$W33]
$GNP12[$W34]
$GNP12[$W35]
$GNP12[$W36]
$GNP12[$W37]
$GNP12[$W38]
$GNP12[$W39]
$GNP12[$W40]
</p>

";
}

if($currentpage == '3'){
print "
<p>
$GNP12[$W41]
$GNP12[$W42]
$GNP12[$W43]
$GNP12[$W44]
$GNP12[$W45]
$GNP12[$W56]
$GNP12[$W47]
$GNP12[$W48]
$GNP12[$W49]
$GNP12[$W50]
$GNP12[$W51]
$GNP12[$W52]
$GNP12[$W53]
$GNP12[$W54]
$GNP12[$W55]
</p>

";
}

if($currentpage == '4'){
print "
<p>
$GNP12[$W56]
$GNP12[$W57]
$GNP12[$W58]
$GNP12[$W59]
$GNP12[$W60]
$GNP12[$W61]
$GNP12[$W62]
$GNP12[$W63]
$GNP12[$W64]
$GNP12[$W65]
$GNP12[$W66]
$GNP12[$W67]
$GNP12[$W68]
$GNP12[$W69]
$GNP12[$W70]
</p>

";
}

?>

<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Navigatie</title>
<style type="text/css">
* {
font-family : Eras Light ITC;
}

body {
margin : 10px;
padding : 0px;
}
</style>
</head>
<body>
<center><?php
echo $output;
?></center>
</body>
</html>

Ik heb ook alles netjes in een .txt file gezet in upgeload in de juiste map.

Maar wanneer ik de pagina open dan krijg ik het bericht: Helaas, deze pagina bestaat niet.

en dat slaat op de volgende code:

PHP:
if ($currentpage < 1 || $currentpage > ceil($totalpages)) {
$output = 'Helaas, deze pagina bestaat niet.';
} else {
$output = navigatie($currentpage,$totalpages,'?p=');
$output .= '<br /><br />Pagina: ' . $currentpage;
}

Dus wie kan mij vertellen welke stomme fout ik gemaakt heb:p
 
Laatst bewerkt:
als ik je script zo bekijk, denk ik dat je de nieuws pagina moet aanroepen als volgt:

[je bestands naam].php?p=1
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan