Post Reply 
included comments list
11-Aug-2011, 08:19 PM
Post: #1
included comments list
Hi all Wink

First of all - sorry about my english, i'm from europe and i haven't spoke/wrote english since a long time^^

i'm actually integrating commentics in my website and what could i say... your script is amazing! thanks a lot!
since now, i could solve every problem using your forum - and i noticed your giving a great support to your users - wow!
---------------------

my problem:

i found the following code in your forum and edited+included it in my index.php to show the latest comments at my main page in a box.


Code:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title></title>

<
style type="text/css">
.
comment {
padding10px;
background-color#ffffff;
overflowhidden;
-
moz-border-radius10px;
-
webkit-border-radius10px;
-
webkit-box-shadow#000000 2px 2px 2px;
-moz-box-shadow#000000 2px 2px 2px;
box-shadow#000000 2px 2px 2px;
border-radius10px;
behaviorurl(/PIE.htc);
margin-bottom20px;
}
</
style>
</
head>

<
body>
<?
php
define 
('IN_COMMENTICS','true');
$path_to_comments_folder "comments/"//Don't forget to change this!
//require $path_to_comments_folder."includes/language/english/database_errors.php"; //load language file for database errors
require $path_to_comments_folder."includes/db/connect.php"//connect to database
$query mysql_query("SELECT comment FROM comments WHERE is_approved='1' ORDER BY dated ASC LIMIT 0, 20");
while(
$comments mysql_fetch_assoc($query)) {
    echo 
"<div class='comment'>";
    echo 
$comments['comment'];
    echo 
"</div>";
        echo 
"<div class='name'>";
        echo 
$name['name'];
    echo 
"</div>";
}
mysql_close($connection); //close connection to database
?>
</body>
</html> 
(Source: Click here)


It works very good and my box looks like this now:
[Image: unbenannt1se.jpg]

What i want to change is
- to show the name and the country
- to show the thumbs-up-icon and the number of "likes" (no dislikes, like facebook)
- to sort them by likes, the most liked comment should be at the top!

Finally it should look like this: (sortet by likes)
[Image: unbenannt1je.jpg]

I've just grafical skills and no great skills in coding, but i'm able to read and change most of the codes... Wink this is my way to create homepages^^

Would anyone be so nice to show me, how the code have to look like to get what i want? Smile

thanks a lot to you all

hope to hear from you soon

Jayson
Big Grin
Find all posts by this user
Quote this message in a reply
11-Aug-2011, 08:40 PM
Post: #2
RE: included comments list
Edit:



Finally it should look like this: (sortet by likes and max. 200 chars shown!)
[Image: unbenannt1cr.jpg]



(i forgot to design max. 200 chars - maybe you can merge this reply with my main entry)^^
Find all posts by this user
Quote this message in a reply
12-Aug-2011, 06:55 PM
Post: #3
RE: included comments list
Hi,

This post contains a slightly simpler alternative:
http://www.commentics.org/forum/showthre...38#pid1938

In that example you can add extra lines to output more data, like:

PHP Code:
<?php
$link 
mysql_connect("localhost""mysql_user""mysql_password");
mysql_select_db("database"$link);

$result mysql_query("SELECT * FROM comments WHERE is_approved = '1' ORDER BY vote_up DESC LIMIT 5"$link);

while (
$comments mysql_fetch_assoc($result)) {
    echo 
$comments["name"];
    echo 
substr($comments["comment"], 0200);
    echo 
$comments["country"];
    echo 
$comments["vote_up"];
    echo 
"<p />";
}
?>

Also note that I have changed "ORDER BY dated" to "ORDER BY vote_up".

Have you completed the interview?
Find all posts by this user
Quote this message in a reply
12-Aug-2011, 11:21 PM
Post: #4
RE: included comments list
Hii Steven!

thanks so much, this code is exactly what i've looked for!

After some small edits my box looks now like this!
[Image: unbenannt1cmp.jpg]

Thats nearly what i wanted to get but i've still some questions and i hope you can help me again Wink

- is there a way to get the vote function running? (with the possibility to click on vote from my external box)
- would you be so kind to add the term "from" before the country? (Should only be shown, if someone has entered a country)

Should look like this..
[Image: unbenannt1dn.jpg]

here's my code:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title></title>

<
style type="text/css">
.
comment {
padding10px;
background-color#ffffff;
overflowhidden;
-
moz-border-radius10px;
-
webkit-border-radius10px;
-
webkit-box-shadow#000000 2px 2px 2px;
-moz-box-shadow#000000 2px 2px 2px;
box-shadow#000000 2px 2px 2px;
border-radius10px;
behaviorurl(/PIE.htc);
margin-bottom20px;
}
</
style>
</
head>

<
body>

<?
php
$link 
mysql_connect("localhost""######""######");
mysql_select_db("######"$link);

$result mysql_query("SELECT * FROM comments WHERE is_approved = '1' ORDER BY vote_up DESC LIMIT 0, 10"$link);

while (
$comments mysql_fetch_assoc($result)) {
    echo 
"<div class='comment'>";
    
    echo 
"<b>";
    echo 
$comments["name"];
    echo 
"</b> ";
    echo 
"from ";
    echo 
$comments["country"];
    echo 
" ";

    echo 
$comments["vote_up"];    
    
    echo 
"<br>";
        echo 
$comments["comment"];    
    
  
//  echo substr($comments["comment"], 0, 200);  //not activated while developing

    
echo "<p />";
    
    echo 
"</div>";
}



?>



</body>
</html> 



I tried and tried to do that on my own, but my skills are to weak - i hate myself for beeing such a php n00b Big Grin

i know that this is not a forum, where members can tell their coding wishes to you, but i'm ready to take some paypal donation for commentics and your nice support =)

thanks a lot,

jayson
Find all posts by this user
Quote this message in a reply
13-Aug-2011, 03:56 PM
Post: #5
RE: included comments list
Hi,

I don't mind helping you with the display but I think the functionality, such as voting, should not be separated apart from the main script.

To display the word "from" before the country you could use this bit of code. It will only display it if a country was entered.

PHP Code:
if (!empty($comments["country"])) { echo "from " $comments["country"]; } 

If you have the time it would be great if you answered the interview which is linked to in my signature below.

Have you completed the interview?
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  No comments form appears despite many avenues explored... sherry 14 160 26-Apr-2013 03:05 AM
Last Post: sherry
  Comments number on another page. Edgey 4 439 17-Apr-2013 10:31 PM
Last Post: aww
  How to insert comments into other place? igor74 4 138 08-Apr-2013 01:48 PM
Last Post: igor74
  SSO, dynamically loading comments and customising dcode 4 191 09-Mar-2013 03:22 AM
Last Post: dcode
  Comments Appear on All Pages?! JMG 1 178 26-Feb-2013 06:24 AM
Last Post: JMG
  One url for comments sabrina 1 178 23-Feb-2013 01:25 PM
Last Post: Steven
  Sorting comments in SEF url system otuzel 0 203 26-Dec-2012 03:32 PM
Last Post: otuzel
  The 10 last comments ? besric 4 426 12-Oct-2012 07:58 PM
Last Post: besric
  Pathname to the File that inserts the Comments Box Bill 10 1,087 23-Jun-2012 11:46 PM
Last Post: Bill
  Comments on separate page from form mdrake 1 530 15-Jun-2012 11:19 AM
Last Post: Steven

Forum Jump:


User(s) browsing this thread: 1 Guest(s)