pompey_john Posted May 4, 2005 Posted May 4, 2005 Hi there, I need to create some dynamic code on my site. It would take the form of ... there are (mysql value) of (mysql value) currently (mysql value) Sorry if this is a really simple question but I have no idea how to do it! For example There are currently X downloads for Y OS in Z categories. Also would like a latest X download type comment. Can anyone point me in the right direction please? All help massively appreciated Thanks John Quote
owatagal Posted May 4, 2005 Posted May 4, 2005 How well do you know MySQL? Do you just need help writing the query, or do you also need help getting it to display? The count() function would let you find out how many downloads/OS/categories you have. The exact nature of the query would depend on your current table structure. I use the following to find out how many authors, essays, and journals are listed in three different tables: >$get_nums = mysql_query("SELECT count(Distinct authors.a_id) as a_count, count(Distinct journals.j_id) as j_count, count(Distinct essays.e_id) as e_count FROM authors, essays, journals"); To get information about the latest entry, I generally run something like: >$latest = mysql_query("SELECT * FROM table ORDER BY add_date DESC LIMIT 1"); This only gets the information, obviously; it doesn't display it on the page. And you'd have to adapt this to your tables/database setup, but hopefully it'll give you an idea of how to go about it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.