Jump to content

Recommended Posts

Posted

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

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...