Jump to content

InABoxPr

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

InABoxPr's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Im not great in SQL, so im not positive on how to fix this code. Im trying to make it select everything instead of just "tasks" so later i can use it like: ect.. $fetch = mysql_fetch_assoc($sql); echo($fetch['TaskID']); SELECT Tasks.Task as Task from Tasks WHERE Tasks.ID NOT IN (SELECT complete.TaskID FROM complete WHERE complete.UserID = '1' And heres the PHP code im using to execute the sql code. $sql = mysql_query("SELECT Tasks.Task as Task from Tasks WHERE Tasks.ID NOT IN (SELECT complete.TaskID FROM complete WHERE complete.UserID = '1')") or die(mysql_error());
  2. Alright, i know that. I'm bad in SQL. How can i fix the code to select all of them like im wanting to do. I tried changing it to * but i think i may of deleted the wrong part of the sql statement or put it in the wrong area. Thanks.
  3. Heres my code: $var = ""; $bip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $sql = mysql_query("SELECT * FROM `bots` WHERE ip='$bip'") or die(mysql_error()); $fetch = mysql_fetch_assoc($sql); $bid = $fetch['id']; $sql = mysql_query("SELECT Tasks.Task as Task from Tasks WHERE Tasks.ID NOT IN (SELECT complete.TaskID FROM complete WHERE complete.UserID = '1')") or die(mysql_error()); while ($fetch = mysql_fetch_array($sql)) { $var = $var . $fetch['Task'] . ">>"; $var2 = $fetch['id']; $sql = mysql_query("INSERT INTO `complete` (UserID, TaskID) VALUES('$bid','$var2')") or die(mysql_error()); $var3 = $fetch['complete']; $var4 = $fetch['needed']; if($var3==$var4) { $sql = mysql_query("DELETE FROM `tasks` WHERE id='$var2'") or die(mysql_error()); //Or do DELETE FROM `tasks` WHERE needed=<$var3 } else { $var3 = $var3 + 1; $sql = mysql_query("UPDATE `tasks` SET complete='$var3' WHERE id='$var2'") or die(mysql_error()); } } $var = substr($var, 0, -2); echo ($var); Im trying to make it select more then just "tasks" from the table Tasks, i tried making it say: $sql = mysql_query("SELECT * FROM Tasks WHERE Tasks.ID NOT IN (SELECT complete.TaskID FROM complete WHERE complete.UserID = '1')") or die(mysql_error()); Insead of: $sql = mysql_query("SELECT Tasks.Task as Task from Tasks WHERE Tasks.ID NOT IN (SELECT complete.TaskID FROM complete WHERE complete.UserID = '1')") or die(mysql_error()); But when i used that code i got this error: Notice: Undefined index: Task in C:\wamp\www\FOLDER\getcom.php on line 20 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\FOLDER\getcom.php on line 18
  4. Sorry for tripple posting, i couldnt find out how to edit previous post. I solved all my problems, can someone close this thread
  5. Alright it works now, i have 1 last question. I made it: echo $fetch['Task'] .">>"; instead of echo $fetch['Task'] .">>"; so now it would say (if i have a task) task>> Im using the ">>" as a seperator for later use. How can i make it delete the last / remove the last ">>" out of the echo'd out data. For example if i have tasks: ID | Task 1 | Hello 2 | Hi 3 | oHia It would echo out like: Hello>>Hi>>oHia>> I want it to echo out like Hello>>Hi>>oHia
  6. Alright thanks, I will test it out now. I will reply shortly with the result.
  7. Well im trying to echo out the task, and for now lets say the user id is "1" .
  8. And with that sql query, i would echo out the result for each thing that is returned. So something like $sql = mysql_query("SELECT Tasks.ID from Tasks WHERE Tasks.ID NOT IN (SELECT Complete.TaskID FROM Complete WHERE Complete.UserID = 'some user id')" or die(mysql_error()); while($fetch = mysql_fetch_array($sql)) { echo "$fetch[task]"; }
  9. Ah, i never thought about that. So i would have something like this, Table: Tasks ID | Task Table: Users ID | Username Table: Complete UserID | TaskID I would have the script check if the id of the user is inside the ID column of the Complete table, and if it is it will compare the task id to the task id inside the table task and i will echo out every row that isnt already complete by that user. Im still sorta stuck on how to code this, i understand how to do it but i feel a bit confused when doing this.
  10. Well i have been trying to get this to work for the past 30 minutes, and it just keeps mind fucking me over and over. Heres how my mysql is basicly setup: Table: Tasks ID | Done Table: Users ID | Username Now im the table "tasks" for the column "done" i want it to say like "1,2,3,4,5" the number represents the Users ID. Now i was to echo out each ID in the table tasks that does not contain the users ID I was trying to put the data in the column "done" into a array, and use in_array to compare the user ID and the data, but it wasnt 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.