ערכתי לאחרונה בתאריך 08.04.07 בשעה 01:18 בברכה, MeToR
קודם כל, אתה לא צריך לשרשר גם <br> במידע.show.php, מציג את המידע:
<html dir="rtl"> <body> <center><?php $numlines=count(file("data.txt")); $n=intval($numlines/40)+1; for ($i=1; $i<=$n; $i++) echo "<a href='show.php?page=$i'> $i </a>"; ?> <br> <? $f=file("data.txt"); $lines=array(); foreach($f as $line_num => $line) $lines[$line_num+1]=$line; if (isset($_GET['page'])) { $num=intval($_GET['page']); $from=($num*40)-39; $to=count($lines); } else { $from=1; $to=count($files); } ?> <table border="1"> <tr> <td> שם מלא: </td> <td> דואר אלקטרוני: </td> <td> מספר טלפון: </td> <td> תאריך לידה: </td> <td> מחיקה: </td> </tr> <? for ($i=$from; $i<=$to; $i++) { $a=explode(",",$lines[$i]); ?> <tr> <td> <?= $a[0]; ?> </td> <td> <?= $a[1]; ?> </td> <td> <?= $a[2]; ?> </td> <td> <?= $a[3]; ?> </td> <td> <a href="delete.php?line=<?=$i;?>"> מחיקה </a> </td> </tr> <? } ?> </table> </center> </body> </html>
|
אתה יכול לעשות את רשימת הדפים גם בתיבת SELECT אם בא לך.
delete.php, מוחק שורה מסויימת:
<?php if (isset($_GET['line'])) { $l=$_GET['line']; $f=file("data.txt"); $lines=array(); $i=1; foreach($f as $line_num => $line) { if ($l!=$line_num+1) { $lines[$i]=$line; $i+=1; } } $fp=fopen("data.txt","w"); for ($i=1; $i<=count($lines); $i++) fwrite($fp,$lines[$i]); fclose($fp); header("location: show.php"); } else { echo "<center>"; echo "שגיאה בקבלת שורה, אנא היכנס שנית דרך <a href='show.php'> דף המידע </a> "; echo "</center>"; } ?>
|
