Aşağıdaki kod benim metin dosyasına insanları listeler benim php dosyasıdır.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>viewlist php</title>
</head>
<body>
<h1>List</h1>
<?php
$file = file("peoplelist.txt");
for($i=0; $i<count($file); $i++)
{
$person = explode(",", $file[$i]);
echo "<hr />";
echo "<table cellspacing=10><tr><td>", $i+1,".", "</td>";
echo "<td>", $person[0], "<br />";
echo $person[1], "</td></tr></table>";
}
?>
<hr />
<p>
<a href="sortatoz.php" target="_self">Sort A-Z</a><br />
<a href="sortztoa.php" target="_self">Sort Z-A</a><br />
</p>
</body>
</html>
what i want to do is, when i click Sort A-Z link, the file called sortatoz.php will sort the list in my text file and redirect back to viewlist.php with the list in sort order. below is my sortatoz.php:
<?php
header("Location: http://myserver/workspace/viewlist.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>sort a to z</title>
</head>
<h1>List</h1>
<body>
<?php
$file = file("peoplelist.txt");
sort($file);
for($i=0; $i<count($file); $i++)
{
$person = explode(",", $file[$i]);
echo "<hr />";
echo "<table cellspacing=10><tr><td>", $i+1,".", "</td>";
echo "<td>", $person[0], "<br />";
echo $person[1], "</td></tr></table>";
}
?>
<hr />
<p>
<a href="sortvisitorsascending.php" target="_self">Sort Visitors A-Z</a><br />
<a href="sortvisitorsdescending.php" target="_self">Sort Visitors Z-A</a><br />
</p>
</body>
</html>
i sırala AZ linki tıkladığınızda artık, bu yüzden) işlevi bu kadar iş yapıyor (başlık varsayarak yaşıyorum ... viewlist.php geri yönlendirir.
ama sorun sıralama değil ... değildir.
i am very new with this, so bear with me and give me some guidance please. what can i do to my codes to redirect back viewlist.php with sorted list?
şimdiden teşekkürler.