Jump to content
#StayAtHome ×

Jim R

  • Content Count

  • Joined

  • Last visited

  • Days Won


Jim R last won the day on July 26 2018

Jim R had the most liked content!

Community Reputation

1 Neutral

About Jim R

  • Rank
    Prolific Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Never mind. I'm pretty sure @kicken output worked. I might've gotten my wires crossed. Thank you to both of you for your time.
  2. Upon further review, it's reversing the results, and reversing the +/- logic changes the rows that haven't had any action on them yet.
  3. Left joining as you had it didn't change anything, unless there was something in the output I needed to change. My query had a left join too.
  4. That's pretty damn close. For some reason it's not recognizing the last row of the data table, or let's say I have a + where there should be a -. I'm going to play around with what @Barand suggested too. I have a LEFT JOIN, but it's bookmark Left Join players instead of what Barand has.
  5. I have 64 rows of players and want each User to be able to choose to bookmark an player, as well as unbookmark it too. I have a bookmark table set up, and each time a User decides to bookmark(+) or unbookmark(-) an player a row is created in the data table. (Matching the player ID and User ID) That's working fine. A query reads the most recent row for each player to determine if there is a + or - button next to each player. Testing the query and adding some dummy data, that part of it works too. However, the issue is the initial state, which I want to be a +. Once I go live, the table will be empty, nothing for the query to return/produce. How do I create an initial state of a + with no rows and have it not used or swapped out when Users start clicking + or -? $query = "SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1 "; $results = mysqli_query($con,$query); echo mysqli_error($con); while($row = mysqli_fetch_assoc($results)) { echo $row['bookmark']; if($row['bookmark'] == 0) { echo '-'; // this is where a form goes to remove a bookmark } else { echo '+'; // this is where a form goes to add a bookmark } } I tried to get it with CASE, but I don't think that's the right path. I also looked at UNION. I was able to get it to produce an initial state of +, but it still printed the already made up sample data too (so I have three instances of ++ or +-). (Players 2, 4 and 4) Here is the what the UNION query looked like: $query = "(SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1) UNION (SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."' ORDER BY p.id desc LIMIT 1) ";
  6. So the AJAX is in addition to the form and query? I've never dealt with if ($_SERVER['REQUEST_METHOD']==='POST') while having the form method being a file.
  7. ha...so the query is good, but the placement isn't. It is inside the loop that's creating this table... I have a + image trying to replace the Submit button (working on that), and I have it put next to each player's name. My thinking after seeing the simple INSERT query produce 64 rows (one for each player), was creating the join with a_players on the insert so I could create one match. (The ID number showing was just my way of knowing it was being passed.
  8. $query = "INSERT INTO a_player_bookmark (playerID,bookmark) VALUES ('".$pid."', 1) "; It's producing correct values for 64 rows.
  9. I tried it without the join and got the same result. It posted the correct playerID and bookmark = 1...64 rows.
  10. No, I'm trying to insert one row of data for each submit, allowing the User to bookmark a player to follow.
  11. Just one, and not even any of the ones on that particular query. So my understanding of what I have is the SELECT instances are the values for playerID and bookmark. If not, then I'm mistaken on what that query is doing. I Googled php, mysql, insert, join. Found about six or seven resolved questions on a couple of different places. They all had that syntax, without any explicit VALUES terms, so I assumed what was in that SELECT were the values being inserted.
  12. I got my code to work without an error, and I thought I would be able to expand on that by Joining my a_players table so I can match the player's ID. Figured out the syntax of it (I think), but instead of just inserting one row for the playerID, it inserts the playerID for every possible row. In this case 64 rows. So I get 64 rows of bookmark = 1 playerID = 251 (for example) - hidden data if (isset($_POST['bookmark'])) { $pid = $_POST['pid']; include("/home2/csi/public_html/resources/con.php"); $query = "INSERT INTO a_player_bookmark (playerID,bookmark) SELECT p.id, 1 FROM a_players p WHERE p.id = '" . $pid . "' "; $results = mysqli_query($con,$query); echo mysqli_error($con);
  13. Just dawned on me (isset($_POST['submit'])) needs to be the name of the button, not the type. It otherwise works.
  14. It's just that above, which then feeds into... function player_name ($nameFirst,$nameLast) { echo '<a href="/tag/'. strtolower($nameFirst) . '-' . strtolower($nameLast) .'">'. $nameFirst . ' ' . $nameLast .'</a> '; echo '<span>' . bookmark_add() . '</span>'; } Once I get it done, it won't be bookmark_add() in there. It will just be bookmark_choose(). I'll have to determine if the bookmark is chosen or not. Right now, I'm just trying to see why the query isn't working.
  • 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.