Aureole Posted July 25, 2007 Share Posted July 25, 2007 I'm trying to add views to my news so it shows how many time a story has been read but I have no idea where to begin, what's the best way to approach this? Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 25, 2007 Share Posted July 25, 2007 <?php $db->query("UPDATE `topic` SET views=views+1 WHERE id = '$topicid'"); ?> Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 25, 2007 Author Share Posted July 25, 2007 I didn't think it would be that simple...thanks a lot I'll try it out. Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 26, 2007 Author Share Posted July 26, 2007 This isn't working, at the moment my query is looking like this: $query = "UPDATE news SET views=views+1 WHERE id='$theid'"; $query = "SELECT title, views, full, author, authorid, cat, id, date_format(date, '%a %D %b %Y %H:%i') as prettydate FROM news WHERE id='$theid'"; What's up with it? Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 26, 2007 Author Share Posted July 26, 2007 Do I need to put the two queries into one...somehow...from the looks of it to me I can't and they need to be seperate, but... [sorry for triple post] I didn't realize... Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 26, 2007 Share Posted July 26, 2007 What's up with it? You need to execute the query for anything to happen. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 26, 2007 Share Posted July 26, 2007 $query1="UPDATE `news` SET views=views+1 WHERE `id`='$theid'"; $resuly=mysql_query($query1) or die("mysql_error()"); $query = "SELECT title, views, full, author, authorid, cat, id, date_format(date, '%a %D %b %Y %H:%i') as prettydate FROM news WHERE id='$theid'"; $resuly=mysql_query($query) or die("mysql_error()"); Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 26, 2007 Author Share Posted July 26, 2007 I'm an idiot, thanks. Quote Link to comment Share on other sites More sharing options...
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.