Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Сохранить переменную

2 views
Skip to first unread message

Dimon

unread,
Apr 25, 2008, 3:11:13 AM4/25/08
to
Hi All!
Есть такой вот код. Тут значит из каталога выбирается файл, затем из этого
файла выводятся данные в таблицу по 10 заисей на страницу. Hо при переходе
на следующую страницу переменная $file_name очищается, и ничего не
отображается.
Как это исправить в данном коде?

<?php

if (isset($_GET['event']))
{
if ($_GET['event']=="show")
{
$file_name = $_POST['file_name'];
$perPage = 10;
$currOffset = 0;

if (isset($_GET['st'])) $currOffset = $_GET['st'];
$currNum = 0;
$lines = file("data/$file_name");
$N=count($lines);
$imax = count($lines);

print "<html><head><title>Счетчик</title><META content='text/html;
charset=windows-1251' http-equiv=Content-Type><link rel=stylesheet
type='text/css' href='style.css'></head><body>";

for ($i = 0; $i < $N; $i += $perPage)
{
$currNum++;
if ($i == $currOffset)
{
print ' <b>'.$currNum.'</b> ';
}
else
{
print ' <a
href="page.php?event=show&st='.$i.'">'.$currNum.'</a> ';
}
}

print "<br><br>";
print "<center><table border=1 bordercolor=#e5e5e5 cellpadding=3
cellspacing=1 width=800><TR><td height=20 bgcolor=\"#505050\"
style=\"font-size: 14px; color: #ffffff;\"width=800 align=center
colspan=3><b>Посещения за $file_name</b></td></tr>";
print "<tr bgcolor=\"#e5e5e5\"><td valign=center align=center width=150
style=\"font-size:12px; color: #000000;\"><b>IP</b></font></td><td
valign=center align=center width=150 style=\"font-size:12px; color:
#000000;\"><b>?</b></font></td><td valign=center align=center width=150
style=\"font-size:12px; color: #000000;\"><b>Link</b></font></td></tr>";

$end = $currOffset + $perPage;

if ($end > $N) $end = $N;

for ($i = $currOffset; $i < $end; $i++)
{
$dt=explode("|", $lines[$i]);

print"<td valign=center width=20 style=\"font-size:12px; color:
#000000;\">$dt[0]</td><td valign=center width=20 style=\"font-size:12px;
color: #000000;\">$dt[1]</td><td valign=center width=20
style=\"font-size:12px; color: #000000;\">$dt[4]</td>
</tr>";
}

print"</table></td></tr></table></td></tr></table>";
print "<center><small><font class=txt>Всего записей в базе:
<B>$N</B></font></small></center>";

}
}
else
{

print "<form method=post action='page.php?event=show'>";

if ($handle = opendir('data'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$imax = count($file);
$i=0;
do
{
print "<INPUT TYPE=radio NAME=file_name VALUE=$file>$file<BR>";
$i++;
} while($i < $imax);
}
}
closedir($handle);
}
print "<INPUT type=submit value=\"Выбрать файл\"></form>";

}
?>

Спасибо!


0 new messages