Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Skaityti toliau

Parašė custOm· 2010 Gru. 5 02:12:08
#2

Susitvarkiau. Jei kam idomu koks kodas tai gaudykit :] :

 
<?php
function trim_text($input, $length, $end) {
$last_space = iconv_strrpos(iconv_substr($input, 0, $length,'UTF-8'), ' ','UTF-8');
$trimmed_text = iconv_substr($input, 0, $last_space,'UTF-8');
$trimmed_text .= $end;
return $trimmed_text;
}
 
 
if(isset($_GET['id']) && is_numeric($_GET['id'])) {
 $id = $_GET['id'];
}
else {
 $id = 1;
}
$con = mysql_connect("localhost","nikas","passwordas");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("database", $con);
 
$result = mysql_query("SELECT * FROM news ORDER BY ID DESC");
if(isset($_GET['full'])) {
 $result2 = mysql_query("SELECT * FROM news WHERE id='".$_GET['id']." ORDER BY id DESC'");
 $info = mysql_fetch_array($result2);
echo '<div class="rightpaneltop"><center><h4>'.$info['title'].'</h4></center></div>';
echo '<div class="rightpanel">'.$info['content'].'</div>';
}
else {
 while($info = mysql_fetch_array($result)) {
  echo '<div class="rightpaneltop"><center><h4>'.$info['title'].'</h4></center></div>';
  echo '<div class="rightpanel">'.trim_text($info['content'],125,'... [<a href="news.php?full&id='.$info['ID'].'">Read More</a>]').'</div>';
  echo "<br />";
 }
}
mysql_close($con);
?>