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? Link to comment https://forums.phpfreaks.com/topic/61741-solved-views/ 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'"); ?> Link to comment https://forums.phpfreaks.com/topic/61741-solved-views/#findComment-307370 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. Link to comment https://forums.phpfreaks.com/topic/61741-solved-views/#findComment-307372 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? Link to comment https://forums.phpfreaks.com/topic/61741-solved-views/#findComment-307681 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... Link to comment https://forums.phpfreaks.com/topic/61741-solved-views/#findComment-307712 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. Link to comment https://forums.phpfreaks.com/topic/61741-solved-views/#findComment-307723 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()"); Link to comment https://forums.phpfreaks.com/topic/61741-solved-views/#findComment-307727 Share on other sites More sharing options...
Aureole Posted July 26, 2007 Author Share Posted July 26, 2007 I'm an idiot, thanks. Link to comment https://forums.phpfreaks.com/topic/61741-solved-views/#findComment-307728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.