开发者

Save the rank in the DB

开发者 https://www.devze.com 2023-04-03 10:28 出处:网络
I\'m using this query to classify pages for which users vote for : SELECT p.page_ID , h.point FROM pages p

I'm using this query to classify pages for which users vote for :

  SELECT p.page_ID , h.point
  FROM pages p
    INNER JOIN history h ON h.page_ID=p.page_ID
  ORDER BY h.point DESC

So I know how to display my pages开发者_StackOverflow ranking, but I'd like to save the rank of each page in my table. How do ?


Assuming you have in PHP $rank as the rank value and $pageid as the page_ID you wish to update (and assuming they're both integers not requiring quotes):

UPDATE history SET point=$rank WHERE page_ID=$pageid;

Or if the page does not already exist in the history table:

INSERT INTO history (page_ID, point) VALUES ($pageid, $rank);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号