Jump to content

i need help with comments look please


sofian

Recommended Posts

hi

i have this code on my script :

 

$arr = array(

'avatar'=>$client['avatar'],'message'=>stripslashes($_POST['message']),'username'=>$client['uname'],'created'=>time()

);

echo comment_display($arr);

 

if i submited 4 comments of echo comment_display($arr); start from post 1 it sort them like this :

 

post 4

post 3

post 2

post 1

 

post 1 , post 2 above post 1 , post 3 above post 2 , post 4 above post 3

 

but i want them like this :

post 1

post 2

post 3

post 4

 

post 1 , post 2 under post 1 , post 3 under post 2 , post 4 under post 3

 

how can i make the " echo comment_display($arr); " become under the last post not above .

 

thank you verry much

Link to comment
Share on other sites

comment_display() appears to be a user-defined function. What does the code look like?

 

In the meantime, you could look into the various array sorting functions:

http://php.net/manual/en/array.sorting.php

 

thank you cyberRobot for your help  and reply .

i tryed to use from here

http://php.net/manual/en/array.sorting.php

but i did not succes .

 

but here all the code that i have for the comments :

 

1-

the script :

 

<script>

$(".quick_comment").click(function() {

$(this).next().next().css("display","block");

$(this).next().next().find(".commentmessage").focus();

return false;

});

$(".commentsubmit").click(function() {

if ($(this).prev()[0].value != "") {

var thiscomment = $(this).parents(".quick_comment_form");

var cbox = thiscomment.next().next();

var mbox = thiscomment.find(".commentmessage");

var tbox = thiscomment.next();

cbox.html("<img src=\"'.uhome().'/files/loading.gif\" /> Submitting");

$.post("'.uhome().'/index.php?p=jquery/comment_publish",

{message:mbox[0].value,target_id:tbox[0].value},

  function(data){

cbox.html("");

$(".quick_comment_form").css("display","none");

cbox.after(data);

mbox.attr("value","");

},"html"

);

return false;

}

});

</script>

 

 

2-

the jquery code :  ( function comment_publish )

$arr = array(

'avatar'=>$client['avatar'],'message'=>stripslashes($_POST['message']),'username'=>$client['uname'],'created'=>time()

);

echo comment_display($arr);

 

3-

function comment_display

 

function comment_display($row = array()) {

if (!$row['avatar']) {

$res = sql_query("select avatar from ".tb()."accounts where id='{$row['uid']}'");

$row2 = sql_fetch_array($res);

if (!$row2['avatar'])

$row['avatar'] = 'undefined.jpg';

else

$row['avatar'] = $row2['avatar'];

};

return '

<div class="user_comment">

<table width="100%">

<tr>

<td class="user_post_left" width="40" valign="top">'.avatar($row,25).'</td>

<td class="user_post_right" valign="top">

<strong>'.url('u/'.$row['username'], $row['username']).'</strong>

'.h($row['message']).'

<div class="att_bottom">'.get_date($row['created']).'</div></td>

</tr>

</table>

</div>

';

}

 

thank you verry much

Link to comment
Share on other sites

Try:

 

$newArr =  array_reverse($arr);

 

echo $newArr;

 

 

or asort($arr);

 

thank you punk_runner for this help and reply

 

i cant use $newArr =  array_reverse($arr);  because i need the comment_display function

and this code asort($arr); i tryed it but the result not change .

 

thank you verry much 

 

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.