Jump to content

derekshull

Members
  • Posts

    103
  • Joined

  • Last visited

derekshull's Achievements

Member

Member (2/5)

1

Reputation

  1. StackOverflow for the win: SELECT * FROM activity f INNER JOIN wp_bp_friends n2 ON n2.friend_user_id=f.user_id WHERE n2.initiator_user_id=:userid UNION ALL SELECT * FROM activity f INNER JOIN wp_bp_friends n2 ON n2.initiator_user_id=f.user_id WHERE n2.friend_user_id=:userid ORDER BY datetime DESC LIMIT 8
  2. wp_bp_friends table: id initiator_user_id friend_user_id is_confirmed is_limited date_created 11 24 22 1 0 2013-12-11 11:17:26 Activity table: ID user_id type component filetype group_id content datetime 15 22 accountcreated NULL NULL 0 NULL 2013-12-11 11:17:26 15 22 status NULL NULL 0 Hello World! 2013-12-11 11:17:26 15 24 accountcreated NULL NULL 0 NULL 2013-12-11 11:17:26 15 24 status NULL NULL 0 Whats up 2013-12-11 11:17:26 So with this SQL Statement: $wallsql= $conn->prepare('SELECT * FROM activity f INNER JOIN wp_bp_friends n2 ON n2.friend_user_id=f.user_id WHERE n2.initiator_user_id=:userid ORDER BY datetime DESC LIMIT 8'); Userid 24 can see userid 22's "posts" such as when 22's account was created and his status update. What it NEEDS to do is let userid 22 see userid 24's updates as well. Right now it's one sided. I thought that this would accomplish what I'm wanting where both users and see each others post updates: $wallsql= $conn->prepare('SELECT * FROM activity f INNER JOIN wp_bp_friends n1 ON (n1.initiator_user_id=f.user_id) INNER JOIN wp_bp_friends n2 ON (n2.friend_user_id=f.user_id) WHERE (n1.friend_user_id=:userid) OR (n2.initiator_user_id=:userid) ORDER BY datetime DESC LIMIT 8'); $wallsql->bindParam(':userid', $_SESSION['uid']); $wallsql->execute(); But it doesn't seem to be working.
  3. I am trying to get all the "posts" from a users friends list on their news feed. I'm trying to do so by getting all those posts where the user is the initiator_user_id and get all the posts from the friend_user_id then I want to get all the posts from initiator_user_id where the user's id is the friend_user_id. This is what I have that's messing up: $wallsql= $conn->prepare('SELECT * FROM activity f INNER JOIN wp_bp_friends n1 ON (n1.initiator_user_id=f.user_id) INNER JOIN wp_bp_friends n2 ON (n2.friend_user_id=f.user_id) WHERE (n1.friend_user_id=:userid) OR (n2.initiator_user_id=:userid) ORDER BY datetime DESC LIMIT 8'); $wallsql->bindParam(':userid', $_SESSION['uid']); $wallsql->execute(); Previously this works but it only gets the posts where the user is the initiator_user_id: $wallsql= $conn->prepare('SELECT * FROM activity f INNER JOIN wp_bp_friends n2 ON n2.friend_user_id=f.user_id WHERE n2.initiator_user_id=:userid ORDER BY datetime DESC LIMIT 8'); Any help would be much appreciated!
  4. I have a notifications system and after many late nighters and dr peppers I finally have it working. My only issue is that the notifications "bell" has the number of new notifications in the middle of it. When I click the button it will show me my unread notifications and when I close it the number of unread notifications stays the same. I'm using a sql statement to get the number of unread posts on load but when I click the button to reveal the notifications I'd like it to update the number of unread posts as well. Here's some code I have: //GETS THE NOTIFICATIONS function toggleDiv(divId) { $("#"+divId).show(); $(document).ready(function(){ $("#myContent").load("getnotes.php"); }); } //BUTTON TO PRESS TO SHOW THE NOTIFICATIONS PANEL <a data-ajax="false" href="#myContent" onclick="toggleDiv('myContent');" data-role="button" data-iconpos="notext" class="icon-bell-alt icon-2x" style="background: none; margin-right: 20px;"></a> //SHOWS THE NUMBER OF UNREAD POSTS <div id='notes_number'><? if ($number == "0") { echo $number; } else { echo "<a style='color: #FF0000;'>$number</a>"; }?></div> What can I do to update the number?
  5. I want to put the values in a database to store them if I can.
  6. There are a lot of solutions out there as to how to save the position of draggable DIVs but I haven't found any that will help with using a While loop in php. I have a database of "needs" and I want to display all the "needs" that match the persons username and status=inprogress. This could be 1 need or 1,000,000 needs depending on if the criteria is met. I want to save the position of the need (DIV) automatically when it's moved. Is this possible? Here the code I currently have that displays the "needs" (divs) <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <style> #set div { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 0 10px 10px 0; } #set { clear:both; float:left; width: 368px; height: 120px; } p { clear:both; margin:0; padding:1em 0; } </style> <script> $(function() { $( "#set div" ).draggable({ stack: "#set div" }); }); </script>
  7. Ok after googling more for a while, I came up with this: $alluserslookup = mysql_query("select u.* from users u left join follow f on u.username = f.username and f.followname = '$username' where f.username is null"); while ($allusersrow = mysql_fetch_assoc($alluserslookup)) { $allusers = $allusersrow['username']; echo "<a href='viewprofile.php?viewusername=$allusers'>$allusers</a><br>"; } It's still displaying users that I follow and don't follow though. Basically I'm take a list of all "username"'s from table "users ---> taking a list of all the "followname"'s where "username" == "$username" from table "follow" ----> Then displaying only the names that don't appear in both lists.
  8. I have 2 tables that I want to compare and find the users that the username is not following and then display the username of the person not being followed. Table 1: users Table 2: follow In my head I see table 1 getting a list of all the usernames (column name is "username" from table 1) and then gets a list of all the usernames the user ($username) is not following (column name is "followname" from table 2). How do I make it compare the two lists and not display the usernames the user is following already? Table two is set up like so: (username) (User they follow) username followname derekshull dvdowns derekshull testuser testuser dvdowns Here's what I have so far. It's displaying users, but it's displaying users I follow and don't follow. Weird. $alluserslookup = mysql_query("SELECT * FROM users WHERE username!='$username'"); $thefollowerslookup = mysql_query("SELECT * FROM follow WHERE username='$username'"); while ($followersrow = mysql_fetch_assoc($thefollowerslookup)) { $afollower = $followersrow['followname']; while ($allusersrow = mysql_fetch_assoc($alluserslookup)) { $allusers = $allusersrow['username']; if ($afollower != $allusers) { echo "<a href='viewprofile.php?viewusername=$allusers'>$allusers</a><br>"; } } }
  9. I have a script that displays the States and the cities in that state where we have records. This is the code I had at first: $lookup = "SELECT state, city, count(city) as num FROM needs WHERE country IS NULL AND status='posted' GROUP BY state, city ORDER BY state, city"; if ($result = mysql_query($lookup)) { $num_rows = mysql_num_rows($result); echo "<table>"; $i = 1; $cols = 3; $prev = ''; while ($frows = mysql_fetch_array($result)) { $fcity = $frows['city']; $fstate = $frows['state']; $fcitycount = $frows['num']; // num is holding your count by city if ($fstate != $prev) { echo "<tr><td><h2>$fstate</h2></td>"; $prev = $fstate; } echo "<tr><td><a href='browseresults.php?city=$fcity&state=$fstate'>$fcity, $fstate ($fcitycount)</a></td></tr>"; } echo "</table>"; } When output comes out I want it to look like the following but it doesn't work: Arkansas Tennessee Missouri Searcy, AR (1) Bartlett, TN (1) St. Louis, MO (4) Little Rock, AR (4) Memphis, TN (3) Perry, MO (3) Benton, AR (2) Branson, MO (1) Shell, MO (2) Does anyone know how it can be done? After 5 hours and a stackflow post no one seems to know what's up.
  10. But all hard feelings aside: thank you, you really did end up helping.
  11. I'm pretty sure it's solved. I'll mark it solved and go with it for now, thanks! Also to the snide comment you made earlier, remember you're the 26 year old that started the sarcastic comments. My employees appreciate your "help".
  12. When I run that command I get: Username Followname derekshull dvdowns derekshull ForgottenSong derekshull test derekshull owensinguatemala
  13. I've messed around and still can't figure out why it's showing my posts and the posts of only one person I follow. I don't think it's understanding that I'm following others besides that one user. So is it pulling all the people I follow?
  14. Works great except one thing now. For some reason it's showing my posts and the posts of one other user named "dvdowns" but not the posts of everyone I follow. It's strange.
  15. Ok so I think I get it, let me know if I'm wrong. The WHERE should have been the ON? And I needed to do a JOIN so I did a LEFT JOIN although I'm not sure of the differences. So I put in this: $sql = "SELECT * FROM follow LEFT JOIN needs ON follow.username=needs.needsusername ORDER BY needs.datetime"; $lookupposts = mysql_query($sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysql_error(), E_USER_ERROR); while ($postrow = mysql_fetch_array($lookupposts)) { $description = $postrow['needs.description']; $needsusername = $postrow['needs.needsusername']; $datesubmitted = $postrow['needs.datesubmitted']; echo "<b>User:</b> $needsusername<br><br><b>Description:</b><br>$description<br><br><b>Date Submitted:</b> $datesubmitted<br><br>----------------------------------------<br><br>"; } I didn't get an error but all it shows is User: Description: Date Submitted: but it doesn't show any info. stumped again. But I'm learning. Any direction?
×
×
  • 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.