Link to home
Start Free TrialLog in
Avatar of Mlungisi Ndlela
Mlungisi NdlelaFlag for South Africa

asked on

How can I archieve this

Hi EE.

I have built a website using Mobirise and now what I want to do is to enable the site to accept comments from people and also display them on the page on the section COMMENTS, now the problem is that I want the comments to use the themes format but the problem with that is that the javascript produce and error if I take the entire DIV section that produce this comment style so that it will be applied to each and every comment. Please check the site and click on the Piracy Impact and check the comment section to see how I want all of my comments to show like. I have 2 php files which one is for retrieving the comment and the other for retrieving the name, this helps me to keep the style but this only works for the first comment, then the rest just displays bellow the first comment and without separating the retrieving process the name is not displayed in a correct stye.

Bellow are the codes that I use to retrieve data:

1) Display Comments

   
<?php
    $con = mysql_connect("xxxxx","xxxxx","xxxxx");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("ndlelabyte",$con);
    $article_id = $_GET['id'];
    $query = "SELECT * FROM `ndlelabyte`.`messages` WHERE `articleid` =$article_id LIMIT 0 , 30";
    $condolencey = mysql_query($query);
    while($row = mysql_fetch_array($condolencey, MYSQL_ASSOC))
    {
    $cond = $row['comments'];
    echo "<p>$cond</p>
    ";
    }
    mysql_close($con);
    ?>

Open in new window


2) Displaying the name is the similar code as above but this time I point/retrieve the name.

On my page I have this under the comment section.

   
<div class="mbr-testimonial card">
                            <div class="card-block"><p>
                        <?php include("display_comments.php"); ?></p></div>
                            <div class="mbr-author card-footer">
                                <div class="mbr-author-name">
    <?php include("display_name.php"); ?>
    </div>
    </div>
    </div>

Open in new window


Now as you can see doing this will only show the last comment but if I had placed the DIV inside the php files which retrieves data from a MySQL database I wouldn't have a problem because each message was going to be displayed as it should be with the style I want to keep.

How can I solve this problem?

The site is HERE
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

I am not clear on what your question is - but I do see you are using the mysql library which has been deprecated (and removed in later versions of PHP) - you might want to consider converting to MySQLi.
Avatar of Mlungisi Ndlela

ASKER

My problem is that I want each and every comment retrieved from the database to be displayed in the same style as the one that is currently on the website, I mean each and every retrieved comment must be displayed on its own box exactly as how t is currently on the website please check the site under the comment section and see what I'm talking about.
What am I looking for - the site says please don't post any comments it is under development - which part of it are you referring to?
That part exactly. That is a sample post of how all the post should look like. Now I would archive that easily if I was able to include the
div

Open in new window

to the javascript that retrieves the comments from the database but it shows an error if I include the div there.
Basically I want each comment to display similar to the current comment where the actual comment is inside that styled box and the name of a person posted be below the comment, exactly how it is currently with that one sample comment on the site.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I meant php not javascript
Ok - potential solution provided above.
Thank you, that was exactly what I wanted.
You are welcome.