Forum Moderators: coopster

Message Too Old, No Replies

Dynamic data question

MySQL hit counter refresh data

         

WhatAnIdea

5:10 am on Dec 18, 2003 (gmt 0)

10+ Year Member



Hello,

I'm new here so I hope everyone will forgive me if don't follow proper etiquette. I'm not sure if it's ok to post multiple questions in a single message?

Well here goes...

I have a PHP web page that is linked to a MySQL database for dynamic data and page hit counts. In my SQL statement I have limited the results to 1 record i.e. "DESC limit 1" unfortunately the page shows the same record twice... any idea why that is happening?

Also I would like to refresh the data on the page once a minute, if I use a redirect to the same page the counter increments. How can I prevent the counter from incrementing if the page is refreshed?

Thanks to all who reply

WhatAnIdea

2:03 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



Hello again...

I figured out how to refresh the page without incrementing the hit counter.

Now my only problem is... why do I have two records when I only asked for 1?

Any help would be apprecieted.

Lou

ergophobe

4:37 pm on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld Idea.

Are you looping through the data?

Can you post
- your query
- your "fetch" statement and any looping construct it's in
- how you're doing your output.

Things to check first
- going throw a loop more times than expected
- concatenating a string to itself somehow (i.e a .= operator)
- multiple echo statements.

In terms of etiquette, check out the charter for each forum. I think there are two big rules here

1. No personal URLs. They will be deleted. Valuable resources are usually okay, but anything that could be perceived as commercial or self-promotional is usually not.

2. Always be polite. Treat others as though they were sitting next to you at dinner. No flames, no insults. They too will be deleted.

In time, you will see that these two rules contribute a lot to making this such a worthwhile forum. Stick around. You'll learn tons!

There's sort of a third guideline which ebbs and flows a bit, but in general, try to avoid posting huge sections of code, like an entire file with the subject line "What's wrong with this?" Everyone will be polite if you do (see rule 2), but it's something that periodically comes up as a serious infraction and then wanes until it becomes general practice and then gets declared a faux pas and... you get the idea.

WhatAnIdea

6:19 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



Hello ergophobe,

Thanks for the reply. I don't see (or recognize) any loop constructs and when I echo the number of records, it displays 1. The query and fetch looks like this...

$query_LiveData = "SELECT * FROM wwlivedata ORDER BY DateAndTime DESC LIMIT 1,1";

$LiveData = mysql_query($query_LiveData, $mysql_link) or die(mysql_error());

$row_LiveData = mysql_fetch_assoc($LiveData);

The data is displayed in a table using the following...
<?php echo $row_LiveData['AmbientTmp'];?>

I hope I have provided enough info for you to help. If I haven't please ask.

Thanks
Ideas

ergophobe

6:31 pm on Dec 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If that's your only echo, it must be executing twice somehow...

I assume that it spits out the same data twice, right, rather than two different rows?

Anyway, if you see my post from last night and this morning, it's clear that my head isn't functioning so well right now, so maybe someone else would be more help

Tom

WhatAnIdea

6:33 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



Hello,

I found the culprit... it was a statement that I pasted in not really knowing why, I just followed an example. Once I removed the statement the page displayed as I wanted it to. The statement was:

<?php require_once('../LiveData.php');?>

Once again. Thanks for your help. I'm sure I'll be asking more as time goes on. I have a lot to learn.

Cheers!
Ideas