Forum Moderators: open

Message Too Old, No Replies

Reading and Displaying Data From a Database

Reading and Displaying Data From a Database

         

lindajames

10:39 pm on Mar 22, 2003 (gmt 0)

10+ Year Member



Hello, I have a database with one table called "Statistics" and within that table i have two fields. One called "Country" and the Other called "Total". The the "Total" field represents the total hits ive had from that particular country.

Basically, I want to create a script that will read all that data and present it to me in a understandable HTML format and also i need it to arrange the data according to the country that has the highest amount of hits at the top and the lowest at the bottom.

I would be greatful if anyone can help me out.

Cheers
Linda

txbakers

11:12 pm on Mar 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



select county,total from statistics order by total

This will put the data in the order you need.

Then in your ASP page:

(you would have already set up a recordset object above and named it something.....)
<tr>
<td>Country</td>
<td>Total</td>
</tr>
<% while (!rsStats.EOF) { %>
<tr>
<td><%=rsStats("country")%></td>
<td><%=rsStats("total") %> </td>
</tr>
<% rsStats.MoveNext; } %>

That's all there is to it.

chris_f

3:00 pm on Mar 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Again Txbaker has it right.

The SQL Statement (for access or SQL) while be:
SQL = "SELECT Total, Country FROM Statistics ORDER BY Total desc;"

You can create a recordset is ASP and use the following ASP code to display the data:

<%
While Not RecordSetName.EOF
Response.Write(SQL("Country") & " - " SQL("Total") & "<br>")
RecordSetName.MoveNext
Wend
%>

Chris.