Jump to content

shortysbest

Members
  • Posts

    414
  • Joined

  • Last visited

Everything posted by shortysbest

  1. oh, i forgot, I need to order it by the date of the Post_id row in a different table of the same database. I want to order it by the number of rows of the same post_id in the postvoting table, and then order it by the date field in the posts table where the id of the row is equal to post_id in postvoting.
  2. This basically select posts from the database (post_id is the id of the post its selecting) and ordering this by the number of rows with this post id in it. How can I order this by amount of posts with this id (as currently), AND by date, newest ones first but in the order of number of them in the database. mysql_query("SELECT post_id, COUNT(post_id) FROM postvoting GROUP BY post_id ORDER BY COUNT(post_id) DESC ");
  3. I have a database called "postvoting", It's basically to store when somebody votes on a particular posts. I store the post_id that the user votes on, the users id that voted on it, and the date. What I want to do is find the most popular posts in a given time. So if 4 people voted on the post with the id of 1, and 2 people voted on the post with the id of 2, I want to count the number of rows with post_id='1' A non working example what I want would look something like: $count_votes = mysql_query("SELECT * FROM postvoting WHILE post_id=post_id"); print mysql_num_rows($count_votes); result: 4 or $count_votes = mysql_query("SELECT * FROM postvoting GROUP BY post_id"); print mysql_num_rows($count_votes); result: 4 (counting the number of results in a group) Hope this isn't too confusing. (I've confused myself with this).
  4. If I am making a "Load more comments" button where it loads, lets say 5 more comments each time you click on it, would it be best to use php sessions to store the id of the last comment loaded? And use that to load the next 5?, continually changing the value of the session to the new id? Or is there a better way of doing this? I had been using hidden textfields to do this.
  5. Could somebody explain how part of this code works. Thanks. $('.profile-show-posts li').each(function(){$(this)[$(this).attr('title') === ucwords(page) ? 'addClass' : 'removeClass' ]( 'current-page' ); }); i know how most of this works, just I am not sure as to how the addClass : removeClass works. Like, what does the ? mark do for this function? What does the : mark do for this? What are the purpose of the [] brackets? thanks.
  6. I have a status system, built with ajax, and I need to get the unique id that the database assigns to the post and return it in the results that are appended to the page via javascript, however I'm not sure how the bessst way would be to do this? I have been doing this: ///variables that are sent to the database $session = $_COOKIE['id']; $uid = $_POST['id']; $post = $_POST['post']; $date = mktime(); //way I have got the unique id of this post $query = mysql_fetch_assoc(mysql_query("SELECT * FROM posts WHERE from_id='$session' AND to_id='$uid' AND post='$post' AND date='$date'")); $id = $query['id']; Although that does work, It feels like it might not always be accurate.
  7. Thanks but that didn't work. The dropdown doesn't show.:|
  8. Well no, I was saying that the dropdown menu shows when i remove that line of code, however when i remove that code it doesn't show the background of the navigation bar, which I want it to do. So when I have that line in place, the dropdown menu shows, but the background of the navigation bar does not, and when I do not have that line of code there, the background shows but the dropdown menu doesn't. I need for both to work at the same time.
  9. This example would show what i mean. Currently with the way it is now the dropdown will not show. however if you remove the line i commented next to it works. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Dropdown Menu Structure</title> </head> <style> ul.navigation { font-family: Arial, Verdana; font-size: 14px; margin: 0; padding: 0; list-style: none; overflow: hidden; /*REMOVE THIS OVERFLOW:HIDDEN AND IT SHOWS THE DROPDOWN,CHANGING IT TO AUTO DIDNT FIX IT*/ background-color: #CCC; } ul.navigation li ul li { float: none; margin: 0px; padding: 0px; font-size: 11px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-width: 1px; border-top-style: solid; border-top-color: #DDD; } ul.navigation li a { display: block; text-decoration: none; color: #333; padding-top: 5px; padding-right: 15px; padding-bottom: 5px; padding-left: 15px; background-color: #DBDBDB; } ul.navigation li { display: block; position: relative; float: left; border: 1px solid #CCC; margin-right: 15px; } ul.navigation li ul { padding: 0; display: none; margin-top: 0; margin-right: -1; margin-bottom: 0; margin-left: -1; position: absolute; width: 100%; overflow: hidden; margin-right: -1px; margin-left: -1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: #CCC; border-bottom-color: #CCC; border-left-color: #CCC; } ul.navigation li:hover ul { display: block; } ul.navigation li:hover a { background-color: #F5F5F5; } ul.navigation li:hover li a:hover { background-color: #39F; color: #FFF; } </style> <body> <ul class="navigation"> <li><a href="">No Dropdown</a></li> <li><a href="">Dropdown Menu</a> <ul> <li><a href="">Dropdown 1</a></li> <li><a href="">Dropdown 2</a></li> <li><a href="">Dropdown 3</a></li> </ul> </li> </ul> </body> </html>
  10. I need a navigation bar with overflow:hidden to have the background of navigation bar, and the borders where i want them, however without the overflow:hidden it is just a few pixels height and doesn't wrap around the bar, but with the overflow:hidden it hides the dropdown, how can i get around this?
  11. Hey, I'm back to the point where I want to use uniqid() to tell when a user is logged on, however, i need to store the session id in a cookie as well, to use around the site. So I'm not exactly sure how i should go about this? If i set a cookie with uniqid() how would i assign that id to just that user?
  12. What would the best way be to show when a user is online? Detecting when they close the browser/tab, not just log out?
  13. forgot to mark as solved.
  14. Yeah i had done that too, had an issue, but I believe i know the fix. Thanks.
  15. Yeah. I got it working, however it had some problems. Since the script that updates it runs ever 10 or so seconds, it would append (1) every 10 or so seconds. And if i replace what's in the title it wouldnt show the site name, and the page and all of that. Just everything i tried it wouldn't work right.
  16. Thanks for the responses, Blue, yours works wonderfully. Thanks. MMDE, Thanks for your response, was going to use that method before the last post was made. Appreciate both of your time.
  17. How can i select the last 3 rows in a table and order it by ASC. When i use DESC it displays the results in the wrong order. $query24 = mysql_query("SELECT * FROM notifications WHERE to_id='$session' AND state='1' ORDER BY id DESC LIMIT 3 ");
  18. I have notifications that automatically update every so often, and i want it to append the amount of notifications in the page title. I have other information in the title such as site name, and page etc. How could I append the notifications to the title and keep the other information in the title.
  19. when i click on a <li> element the <ul> event toggles. I have tried this code but it doesn't work. $(document).ready(function(){ $("#notifications").click(function(event) { load_notifications();event.stopPropagation()}); }); #notifications is the parent ul element.
  20. Yeah that's all I'm doing, but thanks
  21. oh, thanks. I have only been working with php for like 5 months and haven't gotten to the security features, which I need to soon.
  22. I am building a social networking site and I would like to have some ideas as to what people really want in a social networking site. All responses are very much appreciated.
  23. oh thanks, setting path fixed it. currently the id is just the auto increment id (since it's not a live site or anything), and this login script was just something i am using for a temporary login until i get to building a full functional login script for a live site. what i was going to do for the id (for cookie) was something like. md5(Email+md5(password)+id) or something. Not sure what the most secure way about it would be.
  24. I am trying to make a login using cookies, I had been using sessions but i need to use cookies for it now. I have a page called login.php, and i use ajax to login. It seems to be setting the cookie and printing the value of it out when i login, however that's about it. When i'm reading the cookie on other pages it doesn't appear to recognize a cookie. However, If i set the cookie on just a regular index page it has no problem with setting it and reading it. it works fine when i do that. This is how i set the cookie on the login page (also the exact code i used to test setting it on the index page): $expire=time()+60*60*24*30; setcookie("id", $dbid, $expire); $session = $_COOKIE['id']; then to read it on other pages i just use: $session = $_COOKIE['id'];
×
×
  • 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.