Results 1 to 4 of 4
Thread: PHP
Hybrid View
-
14th October 2016 12:40 #1Registered User
Join Date: Sep:2016
Location:
Posts: 18
PHP
, -. . - . , , - . !
:Code:<?php session_start(); $lines = file('sys-for-news/news.txt'); $lines = array_reverse($lines); $last_news = $lines[0]; list ($id, $data, $txtName, $txtZagl, $txtInfo, $ip) = preg_split ("/\|@\|/", $last_news); echo ': <a href="sys-for-news/index3.php">'.$txtZagl.'</a>'."\n"; ?>
Code:<?php include "func.php"; $lines = file('news.txt'); $lines = array_reverse($lines); $item_per_page = 9; if(isset($_GET['page'])) $page = $_GET['page']; else $page = 1; $reji_ot_elem = ($item_per_page*$page)-$item_per_page; $sm = array_slice($lines, $reji_ot_elem, $item_per_page); foreach ($sm as $novini){ list ($id, $data, $txtName, $txtZagl, $txtInfo, $ip) = preg_split ("/\|@\|/", $novini); $txtName = wordlength($txtName, 20); $txtZagl = wordlength($txtZagl, 40); $pic_file = wordlength($pic_file, 40); $txtInfo = wordlength($txtInfo, 5000); echo '<div class="novina"><h3>'.$txtZagl.'</h3>'."\n"; echo '<div class="user"> : <b>'.$txtName.'</b> <b>'.$data.'</b></div>'."\n"; // $gallery = file('gallery.txt'); foreach($gallery as $l){ // id- $match = '/'.$id.'/'; if (preg_match($match,$l)){ list($id, $pic_name, $file_name ) = preg_split("/\|@\|/", $l); echo '<a href="upload/'.$file_name.'"><img src="upload/'.$file_name.'" widht="350" height="250"></a>'; } } echo '<p>'.$txtInfo.'</p>'.'<hr>'."\n". '</div><!-- class="novina" -->'; } // --------- ---------- echo "<br /><br />"; for($x=1; $x<=ceil(count($lines)/$item_per_page);$x++){ if ($x==$page) { echo "$x "; continue; } echo ("<a href=\"index3.php?page=$x\">$x</a> "); } ?>
-
14th October 2016 21:07 #2Mire-x
Join Date: Apr:2005
Location: Sofia
Posts: 763
$limit . - -.Code:<?php session_start(); $limit = 2; $lines = file('sys-for-news/news.txt'); $index = count($lines); if ($limit > $index) $limit = $index; while ($limit--) { list ($id, $data, $txtName, $txtZagl, $txtInfo, $ip) = preg_split("/\|@\|/", $lines[--$index]); echo ': <a href="sys-for-news/index3.php">'.$txtZagl.'</a>'."\n"; } ?>
, , "sys-for-news/index3.php".
"" .
(10b) || !(10b)
-
14th October 2016 22:42 #3Registered User
Join Date: Sep:2016
Location:
Posts: 18
index3.php. , .
Last edited by svetlio2009; 14th October 2016 at 22:48.
-
18th October 2016 12:06 #4Mire-x
Join Date: Apr:2005
Location: Sofia
Posts: 763




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in