Jump to content

I require assistance, simple problem i think


ryogun

Recommended Posts

hello there, im new to these forums and also a newbie at php, and i saw this would be the best place to get help, i have a simple problem i hope, that i dont know how to fix since im not that knowledgeable on php

i have a simple php script that takes out the most recent topics of my forum, the only problem is, when somebody makes one that it is too long, like for example "teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeest" would be too long and mess up my layout because it is on a table, is there a way like if the message is too long, it would be turned like this teeeeeee... and have a certain number of characters that would show up?

example

hello test test test

would be

hello test...

 

help is appreciated  :)

php script bellow

 

 

 

 

 

<?php

//

// Basic Configuration

// How Many Topics you want to display?

$topicnumber = 10;

// Scrolling towards up or down?

$scroll = "down";

// Change this to your phpBB path

$urlPath = "************";

 

// Database Configuration (Where your phpBB config.php file is located

include '**********';

 

// Connecting & Selecting Databases

$table_topics = $table_prefix. "topics";

$table_forums = $table_prefix. "forums";

$table_posts = $table_prefix. "posts";

$table_users = $table_prefix. "users";

$link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Could not connect");

mysql_select_db("$dbname") or die("Could not select database");

 

// Perform Sql Query

$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username

FROM $table_topics t, $table_forums f, $table_posts p, $table_users u

WHERE t.topic_id = p.topic_id AND

f.forum_id = t.forum_id AND

t.topic_status <> 2 AND

p.post_id = t.topic_last_post_id AND

p.poster_id = u.user_id

ORDER BY p.post_id DESC LIMIT $topicnumber";

$result = mysql_query($query) or die("Query failed");

 

// Outcome of the HTML

// Be carefull when you edit these!

print "<marquee id=\"recent_topics\" behavior=\"scroll\" direction=\"$scroll\" height=\"130\" scrolldelay=\"1\" scrollamount=\"2\" onMouseOver=\"document.all.recent_topics.stop()\" onMouseOut=\"document.all.recent_topics.start()\">

<table cellpadding='3' cellSpacing='2' width='50'>";

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

echo  "<tr valign='top'><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#FFCC00\"><b><a href=\"$urlPath/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\">" .

$row["topic_title"] .

"</a></td></font></b><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><font color=\"#C0C0C0\"> by: <a href=\"$urlPath/memberlist.php?mode=viewprofile&u=$row[user_id]\">" .

$row["username"] .

"</td><td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\"><font color=\"#C0C0C0\">" .

date('F j, Y, g:i a', $row["post_time"]) .

"</td></tr></font>";

}

print "</table></marquee>";

 

// Free Result

mysql_free_result($result);

 

// Close the Connection

mysql_close($link);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.