Jump to content
php.lv forumi

php un DB


RaitisRR

Recommended Posts

Sveiki ar šo kodu izvelku no foruma ziņas , ierobežoju to garumu. Kodz paredzēts lai web lapā varu redzēt jaunākos rakstus forumā.

Jautājums tāds - kā būtu iespējams izdrukāt tikai 4 ziņas un kad ir jauna ziņa lai tā parādītos vecākas ziņas vietā.

<?php
function sb($t,$len="100"){
       if(strlen($t) > $len){
       $t = substr($t, 0, $len)."...";
       }
       return $t;
}
$result3 = mysql_query("SELECT * FROM phpbb_posts ORDER BY `post_id` ASC LIMIT 25 ") or die("Nevar savienoties ar tabulu!");
while ($row3 = mysql_fetch_assoc($result3)) { ?>
       <td><b><a href="/forum/viewtopic.php?t=<?php echo $row3['post_id']; ?>"  class="style36"><?php echo $row3['post_subject']; ?></a></b></td>
       <tr><td  class="style35"><?php
	$x=$row3['post_text'];
	echo $x=sb($x, 97); 
	echo "<hr>"
	?>
</td></tr>
<?php
}
?>

Link to comment
Share on other sites

Sveiks. Pēc skata tas ir phpbb lapeles addons vai kas.

Šitā vietā:

$result3 = mysql_query("SELECT * FROM phpbb_posts ORDER BY `post_id` ASC LIMIT 25 ") or die("Nevar savienoties ar tabulu!");

Šito:

$result3 = mysql_query("SELECT * FROM phpbb_posts ORDER BY `post_id` ASC LIMIT 4 ") or die("Nevar savienoties ar tabulu!");

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...