riba Posted September 1, 2006 Report Share Posted September 1, 2006 šo forumu izsērčoju krustam šķērsām kā arī php.net, bet gudrs nēsmu ticis, tātad jautāju Jums: kam jābūt vēl šai scriptā, lai katrai izvadītai rindai ir klāt "delete" poga kas izdzēš konkrēto rindu no teksts.txt faila. <?php $myArray = file("teksts.txt"); $myArray = array_reverse($myArray); $display = 50; $start = ($display) - $display; $news = array_slice($myArray, $start, $display); foreach($news as $key=>$value) { print("$value<br>\n"); } ?> p.s. plz nebļaut esmu beginers Link to comment Share on other sites More sharing options...
Delfins Posted September 1, 2006 Report Share Posted September 1, 2006 print '<input type="button" value="Delete" ... />'; Link to comment Share on other sites More sharing options...
riba Posted September 1, 2006 Author Report Share Posted September 1, 2006 nu jā poga tagat ir, bet man vaig lai tā poga dzēš konkrēto rindiņu pie kuras viņa ir :( Link to comment Share on other sites More sharing options...
v3rb0 Posted September 1, 2006 Report Share Posted September 1, 2006 * katrai pogai rindas nr pieliec. * servera pusē noķer kura poga nospiesta * izdzēs rindiņu priekšā rakstīt ne laika, ne gribēšana. Link to comment Share on other sites More sharing options...
Delfins Posted September 1, 2006 Report Share Posted September 1, 2006 5 Ls Link to comment Share on other sites More sharing options...
v3rb0 Posted September 1, 2006 Report Share Posted September 1, 2006 4.98 Ls ;D Link to comment Share on other sites More sharing options...
goldy Posted September 1, 2006 Report Share Posted September 1, 2006 a saldējumu :) Link to comment Share on other sites More sharing options...
riba Posted September 1, 2006 Author Report Share Posted September 1, 2006 Paldies par neko Link to comment Share on other sites More sharing options...
Stopp Posted September 2, 2006 Report Share Posted September 2, 2006 (edited) rindu laikam izdzēsa ar unset(file("fails.txt")['0']); tas izdzēsīs pirmo rindu. t.i. uztaisi pie katras rindas pogu šādi foreach($news as $key=>$value) { print("$value <a href='dzest.php?rinda=$key'>dzēst</a><br>\n"); } un fails dzest.php izskatās šādi unset(file("teksts.txt")[$_GET['rinda']]); ps. nezinu, vai strādā, man tā tikai liekas ;) edīte: sākumā laikam tikai jādefinē tas file("teksts.txt") kā kāds mainīgais. nu labi uzrakstīšu. dzest.php: <?php $f=file("teksts.txt"); unset($f[$_GET['rinda']]); fputs(fopen("teksts.txt", "w"), implode("\n", $f)); ?> Edited September 2, 2006 by Stopp Link to comment Share on other sites More sharing options...
blackhalt Posted September 3, 2006 Report Share Posted September 3, 2006 Pārdomu versija ~ <?php $kasiko='data.txt'; $fa=file($kasiko); foreach($fa as $num => $line) { echo "<a href=".$_SERVER['PHP_SELF']."?rinda={$num}>Line # {$num}</a> : " . htmlspecialchars($line) . "<br />\n"; } if(isset($_GET['rinda'])){ $cik=count($fa); $fb=fopen($kasiko,'w'); for($i=0;$i<$cik;$i++){ if($i!=$_GET['rinda']){ fwrite($fb,$fa[$i]); } } fclose($fb); } ?> Link to comment Share on other sites More sharing options...
v3rb0 Posted September 4, 2006 Report Share Posted September 4, 2006 if(isset($_GET['rinda'])){ $cik=count($fa); @unset($fa[$_GET['rinda']]); if($cik != count($fa)) { $fb=fopen($kasiko,'w'); fwrite($fb,join("\n",$fa)); fclose($fb); } } Link to comment Share on other sites More sharing options...
riba Posted September 4, 2006 Author Report Share Posted September 4, 2006 Paldies Stopp un Blackhalt, viss notiek un dzēšās kā vajag :) Link to comment Share on other sites More sharing options...
Recommended Posts