How does phpmysql rank by weekly click rate? I am a beginner of my own.

Source: Internet
Author: User
How does phpmysql rank by weekly click rate? I am a beginner of my own. I used multi-table queries, but the following Warning: mysql_fetch_array (): supplied argument is not a valid MySQL result resource is displayed.


Reply to discussion (solution)

This error indicates that your query command is incorrect.
For convenience, please post it and make instructions

Table: tb_members field: mid. shopname indicates the store name, and shoptype indicates the category.
Table: tb_ranking field: rid, mid, hits is the click rate, and date is the time
$ Val is the type uploaded from the home page.
Ranking by store name by weekly click rate
$ SQL = mysql_query ("SELSEC tb_members.shopname, tb_members.mid, tb_ranking. * from tb_ranking inner join tb_members ON tb_members.mid = tb_ranking.rid AND region = '$ val' AND week (tb_ranking.date) = week (now () order by sum (tb_ranking.hits) DEST ");

Can this be written? Never seen
Generally writing
$ SQL = mysql_query ("SELSEC tb_members.shopname, tb_members.mid, tb_ranking. * from tb_ranking inner join tb_members ON tb_members.mid = tb_ranking.rid WHERE region = '$ val' AND week (tb_ranking.date) = week (now () order by sum (tb_ranking.hits) DEST ");

Or not. I have never used this multi-table query.
Is there any other way to sort store names by click rate per week?

That's it.
Your mysql_query ($ SQL) or die (mysql_error ());
Post error message

Warning: mysql_fetch_array (): supplied argument is not a valid MySQL result resource in D: \ AppServ \ www \ shihui \ shoplist. php on line 83
No content


Below is my code
$ SQL = mysql_query ("SELSEC tb_members.shopname, tb_members.mid, tb_ranking. * from tb_ranking inner join tb_members ON tb_members.mid = tb_ranking.rid WHERE region = '$ val' AND week (tb_ranking.date) = week (now () order by sum (tb_ranking.hits) DEST ");

$ Value = mysql_fetch_array ($ SQL);/* Here is the place on line 83 */
If ($ value = false ){
Echo "no content ";
} Else {
Do {
?>


Store name:
"Href =" shop. php? Id = ">
Echo $ value [shopname];
?>


Introduction:



Echo substr ($ value [present], 0,255 );
?>



}
While ($ value = mysql_fetch_array ($ SQL ));
}
?>

$ SQL = mysql_query ("SELSEC tb_members.shopname, tb_members.mid, tb_ranking. * from tb_ranking inner join tb_members ON tb_members.mid = tb_ranking.rid WHERE region = '$ val' AND week (tb_ranking.date) = week (now () order by sum (tb_ranking.hits) DEST ");
It should be: DESC

SELSEC tb_members.shopname,tb_members.mid, tb_ranking.* from tb_ranking INNER JOIN tb_members  ON tb_members.mid=tb_ranking.rid WHERE tb_members.shoptype='$val' AND week(tb_ranking.date)=week(now())  ORDER BY  sum(tb_ranking.hits) DEST

Whether your SQL statement has an error.

Check whether your SQL statement is correct and the mysql execution sequence is correct. first query and then mysql_fetch_array ()

After DESC is changed, it is still the same
I used this multi-table query statement for the first time.

No group by. can sum be used? It is recommended to post
$ SQL = mysql_query ("SELSEC tb_members.shopname, tb_members.mid, tb_ranking. * from tb_ranking inner join tb_members ON tb_members.mid = tb_ranking.rid WHERE region = '$ val' AND week (tb_ranking.date) = week (now () order by sum (tb_ranking.hits) DEST ") or die (mysql_error ());

Error message

Error message You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'selsec tb_members.shopname, tb_members.mid, tb_ranking. * from tb_ranking inner jo 'at line 1

$ SQL = mysql_query ("SELSEC tb_members.shopname, tb_members.mid, tb_ranking. * from tb_ranking inner join tb_members ON tb_members.mid = tb_ranking.rid WHERE region = '$ val' AND week (tb_ranking.date) = week (now () order by sum (tb_ranking.hits) DEST ") the SELECT statement in is incorrect.

Error message
No database selected

There are many problems.
No database selected
This indicates that no database is selected, that is, no mysql_select_db ('database name') statement or error occurs.

On this page, I first use You can query a single table, but not multiple tables.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.