Jump to content

SUBIECTE NOI
« 1 / 5 »
RSS
Vreau sa ofer imprumut pentru con...

Usa de garaj la o magazie existenta

The worst of evil

Proiect de lege: Romanii vor achi...
 Dopuri / casti amortizare zgomot ...

Ce componente trebuie sa schimb d...

2 job-uri de 8 ore simultan.

VW e-Up second hand sau alternati...
 Reparatie scara mozaic vechi

Cablu curte destinat deplasarii l...

Sfat de cumparare pentru un Jagua...

La mulți ani @mishu_bz!
 La mulți ani @kyrre!

PF vinde 3 autoturisme ce se inti...

Suturi la relantii 2.0 tdi + fum ...

Tencuiala exterioara casa caramid...
 

htacces rescriere cu litere mici si excludere caractere speciale

- - - - -
  • Please log in to reply
23 replies to this topic

#19
cezarica

cezarica

    Member

  • Grup: Members
  • Posts: 803
  • Înscris: 15.02.2004
Mda. Am sesizat unele scăpări din partea mea. Ca să fie treaba împăcată scrie într-un fișier separat codul tău pentru a accesa baza de date și următorul cod:
$query = mysql_query("SELECT n.id AS id, n.title AS title, n.staff AS staff, n.news AS news, n.img AS img, DATE_FORMAT(n.date,'%M %d, %Y at %l:%i %p') as date, COUNT(c.comted) as comments FROM news n INNER JOIN comments c ON n.id = c.comted AND c.cgroup = 1 GROUP BY n.id, n.title, n.staff, n.news, n.img, n.date ORDER BY n.id DESC LIMIT $offset, $rowsPerPage") or die('Error: ' . mysql_error());
while ($row = mysql_fetch_assoc($query)) {
print_r($row);
}
atât.

Edited by cezarica, 14 September 2010 - 20:56.


#20
Evollution

Evollution

    Junior Member

  • Grup: Members
  • Posts: 146
  • Înscris: 20.08.2009
se pare ca aceasta variata lucreaza insa apare alta eroare :(

deci am inlocuit :

$output=mysql_query("SELECT id,title,staff,descriere,img,DATE_FORMAT(date,'%M %d, %Y at %l:%i %p') FROM news ORDER BY id DESC LIMIT $offset, $rowsPerPage");

$num=$rowsPerPage;
			if($num>0){
			if($num>4)$num=4;
			$place=0;
while(list($id,$title,$staffm,$descriere,$img,$date)=mysql_fetch_row($output)){
$totalc=mysql_query("SELECT COUNT(*) FROM comments WHERE cgroup='1' AND comted='$id'");

cu codul oferit de tine insa apare unexpected end

Parse error: syntax error, unexpected '}' in /blocks/block-sitenews.php on line 69

am sters acoloada de dupa print_r($row); } .. si-mi apare aceiasi eroare doar ca on line 116 :(

Quote

ps pentru seo cum e mai bine

id-title
title-id sau am mai vazut o varianta de genul title_id care ar fi mai bine ?


#21
cezarica

cezarica

    Member

  • Grup: Members
  • Posts: 803
  • Înscris: 15.02.2004
Dacă nu e strict secret, dă-mi și mie un copy/paste să văd rezultatul. Dacă nu îți văd tot codul n-am cum să ghicesc de ce nu îți merge ție acolo că nu îs medium sau Mama Omida. :) Zi-mi umpic ce logică vrei să aplici că te ajut.

Edited by cezarica, 14 September 2010 - 22:00.


#22
Evollution

Evollution

    Junior Member

  • Grup: Members
  • Posts: 146
  • Înscris: 20.08.2009
<? 
			//Output Content
echo $out[body];

if($index == yes){  

$news_page="{$_GET['news_page']}";
if(!$news_page){
$news_page="1";
}
$news_page=($news_page - 1);
$total=mysql_query("SELECT COUNT(*) FROM news");


$total=mysql_fetch_array($total);
$total="$total[0]";
if ($total == 0){
$out[news1].="There is no current news, you may add news via the Admin Control Panel.";
}

$rowsPerPage = $config[shownews];

// by strangelove we show first page
$pageNum = 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
	$pageNum = $_GET['page'];
}

// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;

$output=mysql_query("SELECT id,title,staff,descriere,img,DATE_FORMAT(date,'%M %d, %Y at %l:%i %p') FROM news ORDER BY id DESC LIMIT $offset, $rowsPerPage");

$num=$rowsPerPage;
			if($num>0){
			if($num>4)$num=4;
			$place=0;
while(list($id,$title,$staffm,$descriere,$img,$date)=mysql_fetch_row($output)){
$totalc=mysql_query("SELECT COUNT(*) FROM comments WHERE cgroup='1' AND comted='$id'");



$url=strtolower($title);
$a = array('ă', 'â', 'î', 'ș', 'ț', ":", '"', "\"", ")", "(", "+", "-", "*", "=", ",",' ');
$b = array('a', 'a', 'i', 's', 't', "", "", "", "", "", "", "", "", "", "", '-');
$titlu= str_replace($a, $b, $url);



$totalc=mysql_fetch_array($totalc);
$totalc="$totalc[0]";
if (strlen($news) > $config[newslength]){
  $news = substr($news,0,$config[newslength]);
  $news .= "...[<a href='./index.php?action=article&art=$id'>Read More</a>]"; }
if($config[cellbgx]==$config[cellbg]){$config[cellbgx]="$config[cellbg2]";}else{$config[cellbgx]="$config[cellbg]";}
$out[news1].="
<div id='news_title_$place' class='news_title' onmouseover=\"viewNews('$place');\"> <div class='subtitle' ><a href='http://www.fifago.com/news/$titlu-$id.html' title='$title'>$title</a></div> 
<div class='posted_l' >Posted at $date by $staffm</div> <div id='big_img' > <img src='$img' alt='$title' style='width: 127px; height: 77px;' /> </div> <div id='text'>$descriere</div>
<div class='read_more_l'><a href='http://www.fifago.com/news/$titlu-$id.html' title='$title'>Read more about this news ? </a></div> </div> <div class='clear'></div>
 <div id='news_title_little_$place' class='news_title_little' onmouseover=\"viewNews('$place');\"> <div id='small_img' > <img src='$img' alt='$title' style='width: 53px; height: 33px;' /></div> 
<div style='float:left;'> <div id='small_subtitle' ><a href='http://www.fifago.com/news/$titlu-$id.html' title='$title'>$title</a></div> <div id='small_infos'>
 <div id='posted'>Posted at $date by $staffm</div> 
<div class='read_more'><a href='http://www.fifago.com/news/$titlu-$id.html' title='$title'>Read more about this news ? </a></div> </div> </div> </div> 

<div style='clear:both;border-bottom:2px solid #999;'></div> 

 		
"; 


$place++;


} 
	
			}


$maxPage = ceil($total/$config[shownews]);

// print the link to access each page

$self = $_SERVER['PHP_SELF'];
$nav  = '';



// ... still more code coming
if ($pageNum > 1)
{
   $page  = $pageNum - 1;
   $prev  = " <a href=\"./index.php?page=$page\">[Prev]</a> ";


   $first = " <a href=\"./index.php?page=1\">[First Page]</a> ";
}
else
{

   $prev  = ' '; // we're on page one, don't print previous link
   $first = ' '; // nor the first page link
}
if ($pageNum < $maxPage)
{
   $page = $pageNum + 1;
   $next = " <a href=\"./index.php?page=$page\">[Next]</a> ";

   $last = " <a href=\"./index.php?page=$maxPage\">[Last Page]</a> ";
}
else
{

   $next = ' '; // we're on the last page, don't print next link
   $last = ' '; // nor the last page link
}

$out[news1].="
<div class='catPages1' align='center' style='clear:both;' id='pagesBlock1'>
		$first$prev page $pageNum of $maxPage $next$last
	</div>";

echo $out[news1];
}
//End News////////////////////////////////////////////////////////////////////////////////////////////////////////
?> 





nu stiam ca asa arata spoiler aici =-o oricum pui mouse deasupra si vezi

Edited by Evollution, 14 September 2010 - 22:09.


#23
cezarica

cezarica

    Member

  • Grup: Members
  • Posts: 803
  • Înscris: 15.02.2004
Ca să îți faci o idee ia încearcă:
<?php
$excerpt=150;
$items_per_page = $config[shownews];

$inId = empty($_GET["id"]) || !is_int($_GET["id"]) || (int)$_GET["id"] < 1 ? 0 : (int)$_GET["id"];
$current_page = empty($_GET["page"]) || !is_int($_GET["page"]) || (int)$_GET["page"] < 1 ? 0 : (int)$_GET["page"];
$offset = ($current_page - 1);

function cleanURL($title) {
	$title= strtr($title, array('ă' => 'a', 'â' => 'a', 'î' => 'i', 'ș' => 's', 'ț' => 't'));
	return preg_replace(array('/[^a-zA-Z0-9\s]/', '{ +}'),array('', '-'), strtolower($title));	
}
	
function excerpt($str) {
	return substr($str, 0, strrpos($str, ' ')) . '...';
}

if (!empty($inId)) {
	$query = mysql_query("SELECT n.id AS id, n.title AS title, n.staff AS staff, n.descriere AS descriere, n.news AS news, n.img AS img, DATE_FORMAT(n.date,'%M %d, %Y at %l:%i %p') as date, COUNT(c.comted) as comments FROM news n INNER JOIN comments c ON n.id = c.comted AND c.cgroup = 1 GROUP BY n.id, n.title, n.descriere, n.staff, n.news, n.img, n.date WHERE n.id = '$inId'");
} else {
	$query = mysql_query("SELECT n.id AS id, n.title AS title, n.staff AS staff,  n.descriere AS descriere, LEFT(n.news, $excerpt) AS news, n.img AS img, DATE_FORMAT(n.date,'%M %d, %Y at %l:%i %p') as date, COUNT(c.comted) as comments FROM news n INNER JOIN comments c ON n.id = c.comted AND c.cgroup = 1 GROUP BY n.id, n.title, n.descriere, n.staff, n.news, n.img, n.date ORDER BY n.id DESC LIMIT $offset, $items_per_page");
}

while (list($id, $title, $staff, $news, $img, $date, $comments) = mysql_fetch_row($query)) :
$comments = $comments != 1 ? "$comments comments" : "$comments comment";
?>
<h2><a href="<?php echo cleanURL($title);?>"><?php echo $title; ?></a></h2>
<p>Posted at <?php echo $date; ?> by <?php echo $staff; ?>, <?php echo $comments; ?></p>
<p>Decription: <?php echo $descriere; ?></p>
<p>News: <?php echo $news; ?></p>
<p>Read more: <?php echo $id ?></p>
<?php
endwhile;
?>
Modifică $excerpt, e numărul de litere pe care să îl arate pe prima pagină. A, vezi ce faci să nu ștergi 'endwhile' :) Dacă accesezi pagina asta, de exemplu: news.php?id=2 o să îți arate doar știrea cu numărul 2. URL-ul la titlu e cum ai vrut, o să mai trebuiască și ceva modificări în .htaccess ca să îți fie valide adresele respective.

Edited by cezarica, 15 September 2010 - 20:01.


#24
cezarica

cezarica

    Member

  • Grup: Members
  • Posts: 803
  • Înscris: 15.02.2004
În caz că mai ajunge careva pe aici am corectat codul de mai sus:
<?php
$excerpt=150;
$items_per_page = $config[shownews];

$current_page = empty($_GET["page"]) ||  (int)$_GET["page"] <= 1? 1 : (int)$_GET["page"];
$inId = empty($_GET["id"]) || (int)$_GET["id"] <= 0 ? 0 : (int)$_GET["id"];
$offset = ($current_page - 1);

function cleanURL($title) {
	$title= strtr($title, array('a' => 'a', 'â' => 'a', 'î' => 'i', 's' => 's', 't' => 't'));
	return preg_replace(array('/[^a-zA-Z0-9\s]/', '{ +}'),array('', '-'), strtolower($title));	
}
	
function excerpt($str) {
	return substr($str, 0, strrpos($str, ' ')) . '...';
}

if (!empty($inId)) {
	$query = mysql_query("SELECT n.id AS id, n.title AS title, n.staff AS staff, n.descriere AS descriere, n.news AS news, n.img AS img, DATE_FORMAT(n.date,'%M %d, %Y at %l:%i %p') as date, COUNT(c.comted) as comments FROM news n LEFT OUTER JOIN comments c ON n.id = c.comted GROUP BY n.id, n.title, n.descriere, n.staff, n.news, n.img, n.date HAVING n.id = $inId") or die ('Error: ' . mysql_error());
} else {
	$query = mysql_query("SELECT n.id AS id, n.title AS title, n.staff AS staff, LEFT(n.news, $excerpt) AS news, n.img AS img, DATE_FORMAT(n.date,'%M %d, %Y at %l:%i %p') as date, COUNT(c.comted) as comments FROM news n LEFT OUTER JOIN comments c ON n.id = c.comted GROUP BY n.id, n.title, n.staff, n.news, n.img, n.date ORDER BY n.id DESC LIMIT $offset, $items_per_page") or die ('Error: ' . mysql_error());
}

while (list($id, $title, $staff, $news, $img, $date, $comments) = mysql_fetch_row($query)) :
$comments = $comments != 1 ? "$comments comments" : "$comments comment";
?>
<h2><a href="<?php echo cleanURL($title);?>"><?php echo $title; ?></a></title>
<p>Posted at <?php echo $date; ?> by <?php echo $staff; ?>, <?php echo $comments; ?></p>
<p>News: <?php echo $news; ?></p>
<p>Read more: <?php echo $id ?></p>
<?php
endwhile;
?>

Edited by cezarica, 18 September 2010 - 01:12.


Anunturi

Bun venit pe Forumul Softpedia!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Forumul Softpedia foloseste "cookies" pentru a imbunatati experienta utilizatorilor Accept
Pentru detalii si optiuni legate de cookies si datele personale, consultati Politica de utilizare cookies si Politica de confidentialitate