Jump to content

Archived

This topic is now archived and is closed to further replies.

DarthViper3k

Thread views for a Forum

Recommended Posts

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

Share this post


Link to post
Share on other sites

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??

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.