DarthViper3k Posted April 6, 2003 Share Posted April 6, 2003 I\'m coding a forum right now I have the idea I know how to do a lot of it I got all of the root pages working (ie. viewthread.php, index.php, addpost.php, etc) right now I\'m adding all of the other stuff I\'m wanting to put into the forums such as what you see here or on a vBulliten forum thins like how many views a thread has I\'m having a problem though the number of views isn\'t showing up and its not updating the value in the database heres my function to update how many views a thread has [php:1:06e2cae966] function updateviews($topicID) { $views_query = mysql_query(\"SELECT * FROM topics WHERE (views=$views) AND (ID=$topicID)\"); $views = $views++; mysql_query(\"Update topicz WHERE views=\'$views\'\"); } [/php:1:06e2cae966] heres what I have on my viewforum.php for views [php:1:06e2cae966] <?php $views_query = mysql_query(\"SELECT * FROM topics WHERE (views=$views) AND (ID=$topic)\"); ?> <TD> <P><FONT SIZE=\"+1\" FACE=\"Trebuchet MS,Arial,Helvetica\"><?php echo $views[\'views\'] ?></FONT> </TD> [/php:1:06e2cae966] I\'m not sure exactly whats wrong I\'m pretty sure my code is right but then again if it was right it\'d work so its obviously wrong heh anyways if somebody has some ideas on this could use the help Quote Link to comment https://forums.phpfreaks.com/topic/317-thread-views-for-a-forum/ Share on other sites More sharing options...
Avalanche Posted April 6, 2003 Share Posted April 6, 2003 Well, I don\'t know a lot about PHP, but I do spell a lot of things right. [php:1:dbdcaa66c2]function updateviews($topicID) { $views_query = mysql_query(\"SELECT * FROM topics WHERE (views=$views) AND (ID=$topicID)\"); $views = $views++; mysql_query(\"Update topicz WHERE views=\'$views\'\"); }[/php:1:dbdcaa66c2] Is that z supposed to be an s in your second query?? Quote Link to comment https://forums.phpfreaks.com/topic/317-thread-views-for-a-forum/#findComment-1012 Share on other sites More sharing options...
DarthViper3k Posted April 7, 2003 Author Share Posted April 7, 2003 Well, I don\'t know a lot about PHP, but I do spell a lot of things right. [php:1:c949c10aa3]function updateviews($topicID) { $views_query = mysql_query(\"SELECT * FROM topics WHERE (views=$views) AND (ID=$topicID)\"); $views = $views++; mysql_query(\"Update topicz WHERE views=\'$views\'\"); }[/php:1:c949c10aa3] Is that z supposed to be an s in your second query?? haha dyslexcia a beautiful thing isn\'t it? (my dyslexcia causes me to misspell a lot of things and I rarely see it) that\'ll help with the update function but thats not the main problem the problem is its not displaying the views its not displaying anything when it should be display 0 since 0 is whats in the database so... whats goin on here? edit: ahh... I feel like an idiot already had the code to display the views just had to use it instead of adding more code :roll: so it displays them now but... it doesn\'t update it Quote Link to comment https://forums.phpfreaks.com/topic/317-thread-views-for-a-forum/#findComment-1013 Share on other sites More sharing options...
DarthViper3k Posted April 7, 2003 Author Share Posted April 7, 2003 ok I\'m not sure wats going on right now but I got it to update however its changing it to 0 I can change it in the database but as soon as I view the thread it updates it and becomes 0 again ahh I got it problem solved Quote Link to comment https://forums.phpfreaks.com/topic/317-thread-views-for-a-forum/#findComment-1017 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.