Ciao a tutti, voglio creare una lista e dopo un $_GET che corrisponde all'id nel file (in questo caso) lista.txt ed ecco il tutto:
Codice PHP:
<?php
$nomefile
= getcwd()."/lista.txt";
$nomefile = file($nomefile);
if(
$_GET["id"]) {
$idget = trim(htmlspecialchars($_GET["id"]));
list(,
$file) = each($nomefile);
list(
$id,$link) = split("[|]",$file);
$id = trim($id); $link = trim($link);
if(
$idget == $id) { echo "<b>$idget = $id --- $link</b>"; }
else { echo
"<b>$idget non esiste!!</b>"; }
}
else {
echo
"<table><tr><td>ID</td><td>Collegamento</td><td>Visitare?</td></tr>";
while(list(,
$file) = each($nomefile)) {
list(
$id,$link) = split("[|]",$file);
$id = trim($id); $link = trim($link);
echo
"<tr><td>$id</td><td>$link</td><td><a href=\"index.php?id=$id\">Si!</a></td></tr>";
}
echo
"</table>";
}
?>
lista.txt
Codice:
1|http://www.ciao.it
55|http://www.ereg.replace.com
99|http://www.ebay.com
44|http://google.it
12|http://ciao.it/dir/page.php?var=ko
Solo che mi dice che non esiste (else { .. }) ...perchè? E' il mio scriptino che interagisco con i file di database...Grazie mille...ciao Davide! ^^
PS. Se vi può interessare ho usato questo http://www.mrwebmaster.it/php/artico...tabase_90.html