SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    should be easy but...

    ...i dont know why its not working...

    PHP Code:
    $result mysql_query("SELECT count FROM count WHERE page='$page'");
    while ( 
    $row mysql_fetch_array($result) ) { 

    $count $row[count];
    $count++;

    $sql "UPDATE count SET count='$count' WHERE page='$page'"; } 
    im just trying to add one to the count to show how many times a page has been viewed.
    hmm...

  2. #2
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You aren't actually executing your second SQL statement! You stick it in the $sql variable but you've forgotten to actually execute it.

    That said, there's a much more efficient way of doing what you are trying to do:

    mysql_query("UPDATE count SET count = count + 1 WHERE page='$page'");

    I'm almost certain that works Give it a go and see what happens...

  3. #3
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep thats works thx alot

    i really gotta learn to code PHP more efficiently cos im sure most of my scripts could be about 100 lines shorted if i did
    hmm...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •