-
Posts
902 -
Joined
-
Last visited
-
Days Won
9
Everything posted by doddsey_65
-
the delimiters in the split were not needed. var parts = jQuery(this).attr('class').split("-"); works perfectly. Thanks for the massive help. Couldnt have done it without you
-
this works: jQuery(document).ready(function() { jQuery('img[class^="quick_quote"]').click(function() { var parts = jQuery(this).attr('class').split("|\-|")[0]; jQuery("#message_qr").val(jQuery('#content-'+parts[12]+parts[13]+parts[14]).html()); animatedcollapse.show('quick_reply'); console.log(jQuery('td#content-'+parts[12]+parts[13]+parts[14]).html()); }); }); but thats just assuming the id will be 3 chars long
-
firebug returns null. but when i add the actual id myself: console.log(jQuery('td#content-369').html()); the contents are returned in firebug. so it has to do with the parts array. a simple alert of parts[1] throws an undefined. however an alert of parts[0] throws quick_quote-369
-
yes its a textarea so i tried .val() before but no luck. where abouts in firebug would i need to look? im not getting any errors.
-
sorry i forgot to mention i noticed the typo. heres what i have: jQuery(document).ready(function() { jQuery('img[class^="quick_quote"]').click(function() { var parts = jQuery(this).attr('class').split("/\-/"); jQuery("#message_qr").html(jQuery('content-'+parts[1]).html()); animatedcollapse.show('quick_reply'); }); }); it just isnt inserting the contents of the td into the textarea for some reason.
-
i used the table join as above and added the result in an array. however when there are no likes for a post it displays that there is 1 like for it. a count of the array shows that 1 person likes the post when there is no one in the table that likes it: $like_list = ""; $likes = explode(", ", $post_info['likes']); $amount_likes = count($likes); $slice = array_slice($likes, 0, 3, true); $remain = array_slice($likes, 4, $amount_likes, true); $remain_num = count($remain); if ($amount_likes > 4) { for($i=0; $i<=3; $i++) { $like_list .= $likes[$i].", "; } $like_list .= " and $remain_num others like this - $amount_likes"; } elseif ($amount_likes < 1) { $like_list .= "0 Users Like This - $amount_likes"; } elseif ($amount_likes <= 3) { $like_list .= $post_info['likes']." likes this - $amount_likes"; }
-
sorry but theres no text going into the quick reply textarea. I changed the ids and classes to include the hyphen but nothing changed. Thanks for all of your help so fay btw. I appreciate it.
-
no luck. it opens the quick reply div as it should but no content is going into the textarea
-
i didnt put the pre tags, i copied it from the source so i dont know what happened there. here is the live example: http://www.thevault.cz.cc/f/new_features/t/post_attachments/p/339
-
the button: [pre]<img class="quick_quote339" style="margin-right:10px;" src="[url=http://www.phpfreaks.com/forums/view-source:http://localhost/ASF/template/default/icons/quick_quote.png]http://localhost/ASF/template/default/icons/quick_quote.png[/url]" alt="Quote Post" title="Quote This Post">[/pre] the td: [pre] <td class="post_content" id="content339"> It is now possible to add attachments to your posts. At the very bottom of the post reply page you can choose to add them. You can add a max of 5 attachments to any one post.<br /> <br /> The attachments are not queued. They will upload at the same time as each other.<br /> <br /> You can also add descriptions for every attachment you upload.<br /> <br /> At the present time attachments will always appear at the bottom of your posts. I am working on a way to make a button so you can place them inline with the content of your post.<br /> <br /> Thanks <br /> [/pre][pre]Carl <div class="ind_post_stats"> <span class="like">0 People Like This</span> </div> </td> [/pre] the quick reply box: [pre]<div id="quick_reply"> <form name="quick_reply_form" method="post" id="quick_reply_form"> <input type="hidden" id="user_name" name="username" value="" /> <input type="hidden" id="subject" name="subject" value="Post Attachments" /> <input type="hidden" id="method" name="method" value="quick_reply" /> <input type="hidden" id="pid" name="pid" value="341" /> <input type="hidden" id="tid" name="tid" value="123" /> <input type="hidden" id="fid" name="fid" value="3" /> <input type="hidden" name="avatar" id="avatar" value="" /> [/pre][pre] <input type="hidden" name="sig" id="sig" value="" /> <input type="hidden" name="color" id="color" value="00f" /> <input type="hidden" name="time" id="time" value="2011-01-20 10:11:25" /> <input type="hidden" name="time_abs" id="time_abs" value="{TIME_ABS}" /> <textarea id="message_qr" name="message_qr"></textarea> <label for="new_post_btn" id="new_post_btn_img" style="display:none;"> </label> <input id="new_post_btn" type="submit" name="new_post_btn" value="Add Reply" /> [/pre][pre] <input id="clear_btn" type="reset" name="" value="Clear" /> <input id="close_btn" onClick="javascript:animatedcollapse.toggle('quick_reply')" type="button" name="" value="Close" /> </form> </div> [/pre]
-
post_display.html <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function() { var pid = "339"; var npid = (339 + 10); for (var i=pid; i<=nid; i++) { jQuery("img.quick_quote"+[i]).click(function() { jQuery("#message_qr").html(jQuery("#content"+[i]).text()); animatedcollapse.show('quick_reply'); }); } }); </script> <div class="post_header" id="{P_ID}"> <span style="float:left;"> {P_TITLE} </span> <span style="float:right;"> {P_AUTHOR} </span> </div> <table class="posts" id="post_display"> <tr> <td class="post_info"> <span class="post_avatar"> {P_AVATAR} </span> <span class="post_sig"> {P_SIG} </span> <span class="post_options"> {P_OPTIONS} </span> <span title="{P_ABS_DATE}" class="post_date"> {P_DATE} </span> </td> </tr> <tr> <td class="post_content" id="content{P_ID}"> {P_CONTENT} {P_ATTACHMENT} <div class="ind_post_stats"> <span class="like">{LIKE_LIST}</span> </div> </td> </tr> </table> as i said before {P_ID} is replaced as this is just the html file which is called by the php file to display the page contents. view_post.php $post_options .= "<img class=\"quick_quote$post_id\" style=\"margin-right:10px;\" src=\"{$config['asf_root']}template/default/icons/quick_quote.png\" alt=\"Quote Post\" title=\"Quote This Post\">"; $rep = array( "{P_AVATAR}", "{P_SIG}", "{P_OPTIONS}", "{P_CONTENT}", "{P_TITLE}", "{P_AUTHOR}", "{P_DATE}", "{P_ATTACHMENT}", "{P_ID}", "{P_ABS_DATE}", "{SITE_ROOT}", "{LIKE_LIST}"); $disp = array( "<img class=\"avatar_icon\" src=\"{$config['asf_root']}avatars/{$post_info['user_avatar']}\" alt=\"avatar\" />", asf_bb_parser($post_info['user_sig']), $post_options, asf_bb_parser(htmlspecialchars(stripslashes($post_content))), $post_title, $post_author, $post_date, $attachment_list, $post_id, $p_abs_date, $config['asf_root'], $like_list); echo str_replace($rep, $disp, file_get_contents("html/post_display.html")); any better?
-
note: {P_ID} is replaced with $pid when the script is called by the php file. for ease just think of it as "1"
-
<script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function() { jQuery('div.nav a').smoothScroll(); var pid = "{P_ID}"; var npid = ({P_ID} + 10); for (var i=pid; i<=nid; i++) { jQuery("img.quick_quote"+[i]).click(function() { jQuery("#message_qr").html(jQuery("#content"+).text()); animatedcollapse.show('quick_reply'); }); } }); </script>[/i] a page displays 5 posts. theres a button next to each post with a class of quick_reply123 where 123 is the id of the post. When this button is clicked it sends the text content of the post td with the id of content123 into the quick reply box at the bottom. Thanks
-
even when i add that and click the image button it only adds the content of the first post to the quick reply box and not the content of the post i am clicking. since that is just looking for a td that has an id that starts with content. they all start with content and then have their post id after it.
-
thanks it works fine. One last thing though. I want to display the first 4 usernames and then show the rest as a numerical representation. eg: user1, user2, user3, user4 and 5 others like this any ideas?
-
forum_posts: post_id post_subject forum_post_likes: like_id post_id like_username basically show all like_usernames under the post they refer to.
-
i am using jquery so that when someone clicks on the quote button next to a post the quick reply field is populated with the content of the post. I have gotten it to work but the problem is multiple posts. here is the code now: <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function() { jQuery(".quick_quote").click(function() { jQuery("#message_qr").html(jQuery("#content").html()); animatedcollapse.toggle('quick_reply'); }); }); </script> <img class="quick_quote" src="img" /> but that image is at the end of every post so i want it to be img class="quick_quote{post_id} but how would i work the jquery that way because it would no longer be ".quick_quote as it has the post id at the end aswell to differenciate.
-
im trying to join my likes table with my post table to display who likes the relevant post. Unfortunatly it is displaying the post several times for how ever many likes there is because of the way i have joined it: $post_query = mysqli_query($link, "SELECT p.*, u.user_id, u.user_username, u.user_avatar, u.user_sig, l.post_id, l.like_username FROM ".TBL_PREFIX."posts as p LEFT JOIN ".TBL_PREFIX."members as u ON p.post_poster = u.user_username INNER JOIN ".TBL_PREFIX."post_likes as l ON p.post_id = l.post_id WHERE p.topic_id = '$topic_id' ORDER BY post_time ASC ") or die(mysqli_error($link)); $likes = array(); while ($post_info = mysqli_fetch_array($post_query, MYSQLI_ASSOC)) { $likes[] .= $post_info['like_username']; what would be the best way to perform this join? like table is as follows: like_id post_id like_username 1 340 doddsey65
-
i had thought of that and it would be alot simpler. But what happens if there are housands of people liking thousands of posts. That table would get preety big.
-
i am trying to add a like system to my forum similar to facebook where it shows how many people like a post. this is my code so far: $like_list = ""; $likes = explode("|", $post_info['post_likes']); $amount_likes = count($likes); $ac_likes = ($amount_likes / 2); $slice = array_slice($likes, 0, 4, true); $remain = array_slice($likes, 4, $ac_likes, true); $remain_num = count($remain); if ($ac_likes >= 4) { for($i=0; $i<$ac_likes; $i+=2) { $like_list .= $likes[$i].", "; } $like_list .= " and $remain_num others like this"; } elseif ($amount_likes == 1 ) { $like_list .= "0 people like this"; } elseif ($ac_likes == 1) { $like_list = implode(", ", $likes); $like_list .= " likes this"; } else { $like_list = implode(", ", $likes); $like_list .= " like this"; } $post_info['post_likes'] contains data like: user1|123456789|user2|123456789 where the number is the timestamp. unfortunatly $like_list prints the username and the timestamp when i would like it to only display the username. This means printing every 2nd element in the array starting from 0. I have seen this done with for loops but i am not using one therefore i am stuck. Any ideas? and is this the best database setup for likes? the post_likes column is added on to the end of the post table.
-
another thing is that i am showing who likes the post under the post which means the date will be shown aswell, but i only want the username shown. what about adding another field called like_date after post_likes. data will be added into them at the same time which means the first username in post_likes will match the first date in likes_date
-
makes sense but how would i pair them? like when i echo them i mean?
-
so something in the database like: user1 | date, user2 | date, user3 | date
-
that does help thanks but i have a question. I am adding a like system to my forum similar to facebook where you can like a post then it will display the amount of likes for that post. Presently i have added a post_likes column at the end of the post_table in the database and populated this with usernames. I can get the number of people who like this by counting the array and i can grab the usernames. however i cannot add a date the post was liked and i dont know how i would do that. so i thought of having a seperate table called post_likes where i can save the uid and the pid and the date. but this means a row in the database for every like which could be thousands. which way is better do you think?
-
how would i add text onto the end of a varchar field? i have tried using update like so: mysqli_query($link, "UPDATE ".TBL_PREFIX."posts SET post_likes = post_likes + ', $qu' WHERE post_id = '$post_id' ")or die(mysqli_error($link)); but that set the table to 0. Any ideas?