Jump to content


Photo

Thread views for a Forum


  • Please log in to reply
3 replies to this topic

#1 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 06 April 2003 - 11:10 PM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#2 Avalanche

Avalanche
  • Members
  • PipPipPip
  • Advanced Member
  • 73 posts

Posted 06 April 2003 - 11:59 PM

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??
DEFINE("YOU","Spending Too Much Time On The Computer");

#3 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 07 April 2003 - 12:29 AM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#4 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 07 April 2003 - 01:35 AM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users