Jump to content

shortysbest

Members
  • Posts

    414
  • Joined

  • Last visited

Everything posted by shortysbest

  1. my friends database is set up with two columns, friend_1 and friend_2. The code I use to find friends of a single user is: $find_friends = mysql_query("SELECT * FROM friends WHERE (friend_1='".$id."' OR friend_2='".$id."')"); however now I need to select the rows that two users have in common. for instance: friend_1 -------friend_2 1 ------------------2 6 ------------------2 2 ------------------7 6 ------------------1 1 ------------------7 so if 1 is me and 2 is the users page I'm on, it should return 6,7. (not returning my or the users id) what makes it complicated is that the ids of users can be in either row, so u can't just select 1 row and compare to the other.
  2. I have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. $from = "Kithell <[email protected]>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers);
  3. Thank you, I got it working how I wanted. And as to what I called a hash based website I mean it uses javascript to load all of the content rather then just regular pages. for instance my website that's hash based the url looks like www.kithell.com#/home rather than something like www.kithell.com/home or www.kithell.com?page=home This way it doesn't have to reload all of the head content, such as the Jquery files, css, other javascript files that are large. Also allows for a lot of nice features other websites cannot have with a regular navigation system. For instance mine has it so you can watch youtube videos and switch through the pages while continuing to watch it without ending it.
  4. I've got everything working well except for one thing. My website is primarily hash based, so when i am using the $(window).unbind('scroll') it doesn't work for other pages that use this code to load more comments, so I need to rebind the scroll event to window when hash changes, like: $(window).hashchange(function(){ $(window).bind('scroll'); }); However that doesn't work. The code I ended up using for loading comments is: var finished = true; /////////////////// $(function () { $(window).scroll(function () { if ($(window).height() + $(window).scrollTop() >= $(document).height()-135) { loading(); if(finished) { finished = null; if(get('id')) { var id = get('id'); } else { var id = ''; } var f_post_id = $(".stream li:last").attr('id'); if(stream_loaded) { $.ajax({ type: "POST", url: "ajax/load_old_posts.php", data: "id="+id+"&post_id="+f_post_id, cache: false, success: function(data) { var check_data = data.replace(/^\s+|\s+$/g, ''); if(check_data) { $(".stream li:last").after(data); $(".stream li").fadeIn("slow"); } var lpostid = $(".stream li:last").attr('id'); if(last_id==lpostid) { $(window).unbind('scroll'); } finished = true; end_loading(); } }); } }} }); });
  5. disregard the last message, I've got everything working well except for one thing. My website is primarily hash based, so when i am using the $(window).unbind('scroll') it doesn't work for other pages that use this code to load more comments, so I need to rebind the scroll event to window when hash changes, like: $(window).hashchange(function(){ $(window).bind('scroll'); }); However that doesn't work. The code I ended up using for loading comments is: var finished = true; /////////////////// $(function () { $(window).scroll(function () { if ($(window).height() + $(window).scrollTop() >= $(document).height()-135) { loading(); if(finished) { finished = null; if(get('id')) { var id = get('id'); } else { var id = ''; } var f_post_id = $(".stream li:last").attr('id'); if(stream_loaded) { $.ajax({ type: "POST", url: "ajax/load_old_posts.php", data: "id="+id+"&post_id="+f_post_id, cache: false, success: function(data) { var check_data = data.replace(/^\s+|\s+$/g, ''); if(check_data) { $(".stream li:last").after(data); $(".stream li").fadeIn("slow"); } var lpostid = $(".stream li:last").attr('id'); if(last_id==lpostid) { $(window).unbind('scroll'); } finished = true; end_loading(); } }); } }} }); }); pardon the mound of code. Again thank you very much for your assistance!
  6. The way my comments are loaded in are after by increments of 5. so every time you scroll to the bottom, or -150 px from the bottom it would load the next 5 until there are no more, I haven't tried the code but it must make it so you can only load comments once, so in that case it would only load the next 5, and if there are more than that to be loaded they wouldn't load again.
  7. Yeah it loads them multiple times because it doesn't have the last id loaded when you're near the bottom of the page. I'm not that familiar with the unbind function so. $(function () { var last_id = null $(window).scroll(function () { if ($(window).height() + $(window).scrollTop() >= $(document).height()-100) { if(get('id')) { var id = get('id'); } else { var id = ''; } var f_post_id = $(".stream li:last").attr('id'); if(stream_loaded) { $.ajax({ type: "POST", url: "ajax/load_old_posts.php", data: "id="+id+"&post_id="+f_post_id, cache: false, success: function(data) { var check_data = data.replace(/^\s+|\s+$/g, ''); if(check_data) { $(".stream li:last").after(data); $(".stream li").fadeIn("slow"); } } }); } }); });
  8. I have a page that loads older comments when you scroll to the bottom of the page, it works well however I want it to load the comments when the user has scrolled to around 200px up from the bottom of the page (so they have a chance to load to help keep the user scrolling down smoothly without breaks from it loading). currently using: $(window).scroll(function () { /* if ($win.scrollTop() == 0) ///scrolled to page top*/ if ($(window).height() + $(window).scrollTop() == $(document).height()) { //code to be executed } });
  9. How would I check this? I know 32bit systems have a default of 4gb, and like 4.2billion rows. I have a 64bit system, so would I be able to have like 130gb?
  10. $(document).click(function(event) { ////Hide Notifications if($(event.target).parents("div:first").attr("class")=="notifications-container"||$(event.target).parents("div:first").attr("class")=="quick-box"||$(event.target).attr("class")=="notifications") {}else { $(".notifications-container").hide(); } }); This is what I replaced it with which works good.
  11. Actually that example above didn't work in safari, well not entirely, however I made a new working script that was better and does work in all major browsers.
  12. Well actually it's an odd problem, there is multiple problems with jquery in Safari, only on localhost though, when I put the files onto my webserver they work fine. I'm not sure what the issue could be for this, not a huge ordeal though as I use Firefox for my primary localhost browser to build with.
  13. I am trying to make a filter to show posts from mutual friends between you and the persons profile you're on, I have somewhat of an idea on how to write the mysql query (it needs to be just one query, not two(which would be the easy way of doing it)). the "friends" table has: "friend_1" and "friend_2" and the "posts" table: "to_id" and "from_id" The PHP variables would be: "$session" and "$id" id would be the users Id of the profile you're on. Thanks, any help would be appreciated.
  14. That seems to work wonderfully, Thanks!
  15. Thank you, but unfortunately that doesn't work :| It doesn't return any results.
  16. I am loading notifications from a database table called "notifications" and I am having a little trouble getting them to order in the correct way. my query I'm using right now: $query = mysql_query("SELECT B.* FROM (SELECT A.* FROM notifications A WHERE A.user_id='$session' AND A.from_id!='$session' ORDER BY A.id ASC ) AS B ORDER BY B.state ASC LIMIT 7"); this works well as far as showing the unread notifications on top, then the read notifications below, however it's not ordering the two sets by ID (which the id auto increments so the higher id number is the newest) from newest on top to the oldest on bottom, still keeping them separated by the unread on top, read on bottom (column name is state for showing whether they're read or not). The order the notifications are displaying by their ID is: 3 5 2 4 1 when it should be: 5 3 2 4 1
  17. I want to have a couple of different formats from mktime(), which the value could be: 1292183335. I would like to have some of the formats like: Tuesday at 12:00am, Wednesday, January 12, 2011 at 12:00am Also taking different timezones in consideration. I'm not sure what to use for that.
  18. Thank you for your time, I actually figured out why it wasn't working, just missing the 'http://', didn't think to put that in.
  19. I'm sending notifications from my website via php mail() function and I am trying to send links but they don't seem to have a link attached to them when they get to my email. my code is: $query = mysql_query("SELECT * FROM users WHERE id='$db_uid'"); $row = mysql_fetch_assoc($query); $from = "notify <[email protected]>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $to = $row['email']; $subject = name($session, 'fl')." posted on your profile."; $message = '<html><body>'; $message .= nl2br(htmlentities($db_post)).'<br /><a target="_blank" href="www.site.com/#/profile&id='.$db_uid.'">Go to your profile</a>'; $message .= '</body></html>'; mail($to,$subject,$message,$headers);
  20. ///Hide Search Suggestions if (!$(event.target).hasClass('search')&&!$(event.target).hasClass('search-suggestions')) { $(".search-suggestions").hide(); } This works perfectly in firefox, but it doesn't in safari.
  21. I have a search set up to search a table for the text entered in a textbox, I have two columns in the table, one with the first name of people, and the second with their last names, I am wondering how I can search both, so for instance: I type in the search field: Roger Smith in the database it would look like: First_name-----|-----Last_name -------------------|------------------- Roger------------|-------Smith my current query is: $query = mysql_query("SELECT * FROM users WHERE fname LIKE '%$find%' OR lname LIKE '%$find%'"); But if I type both parts of the name it doesn't return anything. works fine if I just search for "Roger" OR "Smith".
  22. I have a table called "friends" and 4 columns called: id......friend_1......friend_2.......date I want to retrieve all of the friends of the user that is logged in, so if the table looks like: friend_1.........friend_2 3.........................6 6.........................8 12.......................3 the result if the users id is 3 would be: 6 12 and if the users id was 6 it would be: 3 8 the query I have right now partially works, just note sure how to modify it to get the full result I want. $get_friends = mysql_query("SELECT * FROM friends WHERE (friend_1='".$session."' OR friend_2='".$session."')"); while($friends = mysql_fetch_array($get_friends)) { print $friends['friend_1']; } with the code above if you use the table I showed above and assumed that $session = 3, the result is: 3 12 but should be: 6 12 hopefully that's pretty straight forward, thanks in advanced.
  23. I have two mysql tables, one is called "posts", the other is called "removed_posts", I have joined them together and can get some of the information from the tables, but I want to be able to get all of the information. This is my query, and the variables I need the information to go to: $quer = mysql_query("SELECT posts.id, removed_posts.post_id FROM posts, removed_posts WHERE posts.id=removed_posts.post_id AND removed_posts.user_id='".$session."'"); while($get_post = mysql_fetch_array($quer)) { $session = $_COOKIE['id']; $to_id = $get_post['to_id']; $from_id = $get_post['from_id']; $post = linkify(nl2br(htmlentities($get_post['post']))); $date = time_stamp($get_post['date']); $id = $get_post['id']; What that's doing is selecting the id from 'posts' table, and selecting the post_id from the 'removed_posts' table (The query checks to make sure posts.id is equal to removed_posts.post_id), it does that just fine, since I defined what information I wanted it to get in the query, however, now I need to get the other information which will come from the 'posts' table. $get_post['to_id'], $get_post['from_id'], $get_post['post'], and $get_post['date'] I hope that's not toooooo confusing, any help would be appreciated
  24. If I have setInterval at a 1 second delay would it cause the browser/computer to use a lot more ram/cpu then if it were to be 10 seconds, or 60 seconds? Like enough that it could cause problems with somebodies computer. Also, for loading new comments into the page as they come would it be better to use setInterval, or setTimeout and just trigger the function at the end of it so it would act the same as interval just not trigger until it has completed the query.
  25. I have made "live" feeds in the past with jquery ajax/php And I would use setInterval to check for new comments in the database every 10 or so seconds and load any new posts between the time, however I'm wondering if anybody knows of a better way to do this? I personally like how youtube has their automatic feed, it loads 1 new comments instantly, and continuously at the same speed whether it be 1 comment or 100.
×
×
  • 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.