Jump to content

manix

Members
  • Posts

    219
  • Joined

  • Last visited

    Never

Everything posted by manix

  1. No no the sql query works perfectly, as the favorites' default value is ":" and every time a new item is added I add another colon so it becomes ":item1:item2:item3:" here's the update line: mysql_query("UPDATE `users` SET `favorites`= CONCAT(`favorites`,'$id:') WHERE `id`='$userid'"); therefore when an item is removed the colon after it is removed too so the sequence remains the same It's working perfectly brilliant, thank you again!
  2. Holy crap here it is: SELECT * FROM `items` WHERE (SELECT `favorites` FROM `users` WHERE `id`='5') LIKE CONCAT('%:',`ID`,':%') and notice I have colons before and after the percents so it doesn't mess 1 with 10,11,12
  3. Well.. Guess I'll just do it in php, at least I learned alot (based on what I knew before) about sql now. Thanks Keith
  4. actually what I'm trying to do is not that complicated at all it's just I can't explain it, I guess. I'm here now SELECT * FROM `items` WHERE `ID` LIKE (SELECT `favorites` FROM `users` WHERE `id`='5') which is pretty much what I was looking for except I can't manage to figure out how to find the item's ID in the favorites cause I don't know how to put the percent signs around (SELECT `favorites` FROM `users` WHERE `id`='5') which is supposed to be like '%(SELECT `favorites` FROM `users` WHERE `id`='5')%'. Can you help me with that? EDIT: This is error-free but doesn't return anything SELECT * FROM `items` WHERE `ID` LIKE ('%'+(SELECT `favorites` FROM `users` WHERE `id`='5')+'%') EDIT2: Okay, new discovery, I changed the `favorites` glue to " " instead of ":" and now it returns the FIRST favorite..
  5. Hello, I have a "user's favorites" field which contains IDs of items glued with ":" and I need to return all items (located in another table) which is a piece of cake in php but I thought, hey wait a minute I think this can be done in with a single SQL line and I started looking at tutorials and stuff but still got nowhere, so actually what I have is actually I think showing a php code of what I need done in sql would be more appropriate <?php $query = "SELECT `favorites` FROM `users` WHERE `id`='currentuserprofile'"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $favorites = explode(':', $row['favorites']); } foreach($favorites as $value) { $query = "SELECT * FROM `items` WHERE `id`='$value'"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo stuff } } ?>
  6. actually I can, the problem was, as always the dumbest crap, I forgot to include the jquery file... and the code if someone needs it is as follows: var returning = 0; $(window).focus( function() { if(returning==1) { alert("Thanks for visiting!"); returning = 0; } }); $(window).blur( function() { returning = 1; });
  7. I want to send an ajax request to refresh a certain line in my site every time the window is focused, and it's giving me a major headache because neither this function() { $(window).focus(function() { alert("Thanks for visiting!"); }; }); nor this $(window).focus( function() { alert("Thanks for visiting!"); }); alert anything :@
  8. I need to execute a logout.php file upon window closing and here's what I have <script type="text/javascript"> $(window).unload( function () { $.post('logout.php', { id: $('#loutid').html() }, function(returned) { }); }); </script> logout.php <?php if(isset($_POST['id'])) { mysql_query("UPDATE `z` SET `online`='0' WHERE `id`='$userid'"); } ?> I'm guessing that the problem is there's not enough time to execute the script when the user closes the window.. Bad thing is I can't think of anything I can do
  9. Hey, I remember doing this before, but I can't manage to do it now. I have a div inside a div and I want that inside div's position to be at the right of the main div but if I do this <div> <div style="position:absolute;right:0px;"></div> </div> it sends it to the very right of the whole page.
  10. Hey, I'm creating one of those bars where you can see the currently online users, but I'm having trouble with finding out how to detect when a user logs out (or leaves the website with "remember me" checked). How is that done?
  11. I meant, it's you who sends the data, you're supposed to know how to handle it, no?
  12. Hey, I need to know if $_SESSION variables are editable? Because when a user logs in his username is being set in $_SESSION['user'] and it's not coded in any way (by me) so if it is possible to edit a session variable a user can simply change it to the admin's name and do some nasty stuff.
  13. \x ? Can you gimme a tutorial cuz I really suck ..
  14. UPDATE: I actually found out how to do this, but is it a good idea tho ?
  15. Hello, How can I force an input submit button to autoclick when the page is loaded? Or if there's another way to do this here's what I'm trying to do I'm creating a view profile page which is an ordinary public profile viewer but I don't want the link to be something like "/profile.php?id=1203872438974" so instead if $_GET['id'] is set I'm having a form with a hidden input which holds the ID automatically submit it to the same page and this time access it with $_POST so the page would look like "/profile.php"
  16. Hey I have this rewrite rule for my users RewriteRule ^([A-Za-z0-9-]+)/?$ user.php?user=$1 [L,NS] which works perfectly on examples like mysite.com/James mysite.com/William but I need to have examples like this redirected too mysite.com/Иван Is it even possible :/
  17. I am having in mind when someone uses the inspect element (chrome) option to edit something that might result in an error on my script (like hidden inputs in which I pass data to other pages) then I shall terminate the process and send the user to the index page. and I think get_error_last() would do fine. Thank you.
  18. Hello, Is there any way to detect an error/warning/notice that occurs at any point of processing the script?
  19. Actually when will you not know ?
  20. manix

    Backup !?

    actually there's not such an option in my cpanel but anyways I now know how it's done and for further help I shall address my provider, thank you phpSensei (nice nickname too!)
  21. manix

    Backup !?

    Unfortunately for me my webhost is running in windows (didn't see that coming lol...) and I can't really use this I guess
×
×
  • 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.