Jump to content
php.lv forumi

help video script name shorter nestrada


Lancom

Recommended Posts

help video script name shorter nestrada.

kr4 man negrib samazinaties video nosaukums, un vel neuzrada video nosaukumu.
<?php
if($logged_in) {
?>
<a href="/videos/" class="menu"><b>Видео</b></a>
<div class="dotted_hr">
</div>
<br />
<?php
define("INCLUDES_DIR","includes/");
include INCLUDES_DIR . "config.php";
function pagination($count,$perpage) {
   echo "<div class=\"pagination\">\r";
   $between = 5;
   $pages = ceil($count/$perpage);
   if($pages<2)
   {
       echo "";
   }
   $page = (empty($_GET['p']) || $_GET['p']<2) ? 1 : $_GET['p'];
   $first = $page >= $between+1 ? $page-$between : 1;
   $last = $page <= $pages-$between ? $page+$between : $pages;
   if($page>1)
   {
       $p.= sprintf('<a href="/videos/?p=1">«</a><a href="?p=%d">‹</a>', $page-1);
       }
       for($i=$first;$i<$last;$i++)
       {
           $p.= sprintf('<span%s><a href="/videos/?p=%d">%d</a></span>', $page==$i ? ' class="current"' : '' , $i, $i);
           }
           if($page<$pages)
           {
               $p.= sprintf('<a href="?p=%d">›</a><a href="?p=%d">»</a>', $page+1, $pages);
           }
           $p.= "\r</div>";
           echo $p;
           }
           $perpage = 16;
           $_LIMIT = (!empty($_GET['p']) && $_GET['p']>1)?($_GET['p']*$perpage)-$perpage:0;
           $_LIMIT.=", ".$perpage;

           $result = mysql_query("SELECT * FROM ".DB_PREFIX."videos ORDER BY id DESC LIMIT ".$_LIMIT."") or die(mysql_error());
           $count = mysql_num_rows(mysql_query("SELECT * FROM ".DB_PREFIX."videos"));
           while($row = mysql_fetch_array($result))
           {
               $rows = mysql_fetch_array(mysql_query("SELECT * FROM ".DB_PREFIX."videos WHERE id =  ".$row['id'].""));
               printf("
               <div class=\"video_container\">
               <table class=\"video_box1\">
               <tr>
               <td><a href=\"/watch/?id=".$row['id']."\"><img src=\"http://i1.ytimg.com/vi/".$row['embed']."/default.jpg\" alt=\"".$row['name']."\" style=\"120px; height: 70px;\" /></a>
               <td valign=\"top\">» <a href=\"video/watch/?id=".$row['id']."\"><b>".(strlen($row['name'], 0,10))."</b></a>
               <br />» <b>Просмотров: (1)</b>
               <br />» <b>Рейтинг:</b>
               </td>
               </tr>
               </table>
               </div>
               \r");
               }
               pagination($count,$perpage);
               mysql_free_result($result);
               }
else
{
echo "Пожалуйста залогиньтесь, или регистрируйтесь.";
}
?>

Edited by Lancom
Link to comment
Share on other sites

Kur problēma? Mēģini saīsināt nosaukumu šādā veidā?

 

(strlen($row['name'], 0,10))

 

 

Šādi var saīsināt tekstu:

$txt = (mb_strlen($txt, "UTF-8") > 10) ? mb_substr($txt, 0, 10, "UTF-8") . "..." : $txt;

echo $txt;

Edited by 101111
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...