General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 25th, 2002, 02:49 PM
mikle mikle is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 2 mikle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
devarticles.com rating system

hi
Could any1 plz write an article on how to implement a rating system such the one used in devarticiles?!


thanx

Reply With Quote
  #2  
Old September 25th, 2002, 03:13 PM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
I believe one has already been done. Take a look at Annette's article and see if it is what you are looking for.
__________________
Oh I wish, I wish I hadn't killed that fish...

Reply With Quote
  #3  
Old September 25th, 2002, 04:15 PM
mikle mikle is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 2 mikle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanx markerdave

I though it would be a good idea to do it in php! The mentioned article is writen for ASP developeres!

Reply With Quote
  #4  
Old September 25th, 2002, 04:38 PM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
mikle,

Do you know much ASP? I doubt that it would be too difficult to change the code from ASP to PHP.

Reply With Quote
  #5  
Old September 25th, 2002, 05:43 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
read the article, and if you need any help converting the asp to php, just post it here.

Reply With Quote
  #6  
Old September 26th, 2002, 10:28 AM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi there

I am an absolute newbie to PHP, and as such, would not know how to convert the code from ASP to PHP. Would it be possible to have the rating script in PHP?

Thanks in advance.

Reply With Quote
  #7  
Old September 26th, 2002, 05:37 PM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up


Reply With Quote
  #8  
Old September 26th, 2002, 09:00 PM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
1man
I've tried it, but after I click on the button the page stays on rate.php, with nothing showing up. No messages, nothing to say if the value has been entered to the db or otherwise.

btw: the name of my first file is article.php, and following the instructions, second file is rate.php. Am I doing things right?

Reply With Quote
  #9  
Old September 27th, 2002, 08:19 AM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
bigbear
I don't now where is the problem

the code dose not work with me!
i think the problem with id

you will see the URL like this :
http://you.com/rate.php?id=

i will try to check the problem
and answer you


1man

Reply With Quote
  #10  
Old September 27th, 2002, 08:25 AM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes!!! That's the exact thing that I see when I click the button. The page is empty, and the URL is the way you described it.

Being a newbie to something as powerful and useful as PHP sucks... hopefully the book which I ordered will reach me soon.

Reply With Quote
  #11  
Old September 27th, 2002, 10:39 AM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb bigbear

OK .. try this scripts..

file name : article.php
PHP Code:
<?
$dbhost 
"localhost";
$dbname "book";
$dbpass "";
$dbuser "";




$DBC = @mysql_connect("$dbhost""$dbuser""$dbpass");
    if (!
$DBC) {
    echo 
"ERROR";
    exit();
    }

# select DB

$DBS = @mysql_select_db("$dbname");
    if (!
$DBS) {
    echo 
"ERROR";
    exit();
    } 
?>

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#EFEFEF" width="100%" id="AutoNumber1" bgcolor="#EFEFEF">
  <tr>
    <td width="100%">
    <?
    $result2 
mysql_query("select * from rates");
while ( 
$row mysql_fetch_array($result2))
{
$id $row["id"];
?>
    <form method="GET" action=rate.php?id= <? echo $id?>>
      <p align="center"><?}?>
      <span class="blackSmall"><font size="1" face="Tahoma">id =
      <input type="text" name="ID" size="2" value="1"><br>
<b>How would you
      rate this article:&nbsp;&nbsp;&nbsp;Bad &nbsp;<input type="radio" value="2" name="rValue" checked>
      &nbsp;<input type="radio" value="4" name="rValue"> &nbsp;<input type="radio" value="6" name="rValue">
      &nbsp;<input type="radio" value="8" name="rValue"> &nbsp;<input type="radio" value="10" name="rValue">
      Good&nbsp;&nbsp;&nbsp;&nbsp; </b></font></span></p>
      <p align="center">
      <input type="submit" value="Rate" name="B1" style="color: #000080; border: 1px groove #000080; background-color: #FFFFCC"></p>
    </form>
    </td>
  </tr>
</table>

</body>

file name : rate.php
PHP Code:
<?
$dbhost 
"localhost";
$dbname "book";
$dbpass "";
$dbuser "";




$DBC = @mysql_connect("$dbhost""$dbuser""$dbpass");
    if (!
$DBC) {
    echo 
"ERROR";
    exit();
    }

# SELECT DB

$DBS = @mysql_select_db("$dbname");
    if (!
$DBS) {
    echo 
"ERROR";
    exit();
    }


$sql mysql_query("SELECT * from rates where id=$ID");
while (
$row=mysql_fetch_array($sql))
{
$id=$row["id"];
$FileName=$row["FileName"];
$Num_Votes=$row["Num_Votes"];
$Votes  =$row["Votes"];
$Rating=$row["Rating"];

$new_Votes=$Num_Votes+1;
$Votes2=$Votes+$rValue;
$Rating=round(($Votes/$new_Votes),2);

$sql2 mysql_query("UPDATE rates SET Num_Votes=$new_Votes, Votes=$Votes2, Rating=$Rating where id=$ID");

if (
$sql2) {
echo  
"Thank you. The article has rating = $Rating after your vote.";
}

}

?>

don't forget create the SQL table :
PHP Code:
 CREATE TABLE rates  (
ID int(5) DEFAULT  '0'  NOT NULL auto_increment,
FileName varchar(50)  NOT NULL,
Num_Votes int(4)  NOT NULL,
Votes int(5)  NOT NULL,
Rating int(5)  NOT NULL,
PRIMARY KEY  (ID)
); 

is every think ok ?

I hope that

1 MaN

Reply With Quote
  #12  
Old September 27th, 2002, 11:30 AM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
1man... it doesn't work. After clicking on Rate button, it just stays at the page. Nothing seem to happen.

btw: How do I use images to display the ratings, and how do I use this on every article page?

Reply With Quote
  #13  
Old September 27th, 2002, 01:04 PM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0

man .. it's work with me !!

did you change any think?

look >> action=rate.php

1- How do I use images to display the ratings ?
use IF and round
like this :
$Rating2 = round($Rating);
if ($Rating = 5)) {
<img src="stars" alt="" border=0><img src="stars" alt="" border=0><img src="stars" alt="" border=0><img src="stars" alt="" border=0><img src="stars" alt="" border=0>
}
do like that with 4 & 3 & 2 & 1
i think .. But maybe that wrong

2- how do I use this on every article page?
go to table Article
and Add :
Votes & Num_Votes & Rate
ID will be article ID
that's all




1 MaN

Reply With Quote
  #14  
Old September 27th, 2002, 01:19 PM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The only thing I changed was the name of the db.

Reply With Quote
  #15  
Old September 27th, 2002, 01:25 PM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0


i don't now where is the problem

check files name

and press on Rate 999 time

Reply With Quote
  #16  
Old September 27th, 2002, 01:41 PM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by 1 man


i don't now where is the problem

check files name

and press on Rate 999 time


The files are all as it should be. Currently I noticed that the form action has only get. Shouldn't there be a form action POST to submit the rating to the db? Am confused.

Is it possible for you to attach the full code for your article.php file? Like I said, the only thing which I changed is the name of the db... I even tried it on my server and it does not work.

x 10

Reply With Quote
  #17  
Old September 27th, 2002, 01:56 PM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
OK
i have attach the article.php file
Attached Files
File Type: zip article.zip (774 Bytes, 739 views)

Reply With Quote
  #18  
Old September 27th, 2002, 04:16 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
bigbear,

Did you make sure to change the table name in the code to reflect the name change?
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #19  
Old September 27th, 2002, 06:42 PM
retr0 retr0 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: UK
Posts: 15 retr0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by 1 man
:eek:
man .. it's work with me !!

did you change any think?

look >> action=rate.php

1- How do I use images to display the ratings ?
use IF and round
like this :
$Rating2 = round($Rating);
if ($Rating = 5)) {
<img src="stars" alt="" border=0><img src="stars" alt="" border=0><img src="stars" alt="" border=0><img src="stars" alt="" border=0><img src="stars" alt="" border=0>
}
do like that with 4 & 3 & 2 & 1
i think .. But maybe that wrong

2- how do I use this on every article page?
go to table Article
and Add :
Votes & Num_Votes & Rate
ID will be article ID
that's all


1 MaN :)



Hello 1 MaN

I used a while loop to output the star graphics coz I'm lazy :o)
See my Web site http://www.developers-resources.net

Here is the code:
Code:

else{

$i = 0;
While (++$i <= $Rating) {

           $rate .= "<img src=$G_URL/graphic/rate.gif border=0 alt=Rated></a>\n";
        }
           $rate .= "<br><strong>Rated: $Rating out of 10</strong><br>\n";

     } // end else


} // end while




You could also use several different images and use a numercal variable to call the graphics instead. But that would be more work :o)

i.e.

$rate .= "<img src=$G_URL/graphic/"."$rating ".".gif border=0 alt=Rated></a>\n";

Last edited by retr0 : September 27th, 2002 at 06:48 PM.

Reply With Quote
  #20  
Old September 27th, 2002, 09:46 PM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by FrankieShakes
bigbear,

Did you make sure to change the table name in the code to reflect the name change?


I used back 1man's table name, rates. It's my own db name which I changed. Tried using 1man's db name as well, didn't work.

1man - still can't work. Downloaded your file and it still stays on the same page without any messages or whatesoever when I click on the button.

Reply With Quote
  #21  
Old September 28th, 2002, 03:28 PM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
retr0

THX


bigbear
??????

Reply With Quote
  #22  
Old September 29th, 2002, 12:36 AM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Been doing this for the past few days. Can't seem to get any of the rating scripts found online to work properly on my machine and on the server. Very strange that you got it working 1man... what version of PHP are you using?

Reply With Quote
  #23  
Old September 29th, 2002, 09:02 AM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
if me using version 3 there is no problem

the problem whit ACTION .. HTML!

that's all

try ..
Press enter when you select the circle

Reply With Quote
  #24  
Old September 29th, 2002, 09:14 AM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hmmm... my server is using PHP4.1 ... and I am using the latest version of PHP on my computer... could be the form actions that are screwing things up... I think I've read some where that PHP4 handles form differently?

Reply With Quote
  #25  
Old September 29th, 2002, 09:27 AM
1 man 1 man is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 9 1 man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
me too using PHP4

Quote:
Press enter when you select the circle


Reply With Quote
  #26  
Old September 29th, 2002, 09:32 AM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by 1 man
me too using PHP4


Urmm... can't really ask my members or users to press enter whenever they want to rate it... can I?

Thanks anyhow... I'll continue to look for other scripts if possible... anyway Magdeline has already submitted a new script to the site. Waiting for Greg to approve it.

Reply With Quote
  #27  
Old September 29th, 2002, 11:23 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Bigbear,

I just took a look at 1man's script... In his <form> tag he has this:

<form method="GET" action=rate.php?id= <? echo $id; ?>>

Try changing it to this:

<form method="GET" action=rate.php?id=<?php echo $id;?>?

Also, you can even use the "POST" method if you wish.

See if that helps.

Reply With Quote
  #28  
Old September 29th, 2002, 02:15 PM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
FrankieShakes: Nope - it didn't work. I am just wondering if there's something wrong with my browser or with some other software which I installed.

Reply With Quote
  #29  
Old September 29th, 2002, 02:38 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Bigbear,

Did you replace all "<?" tags with "<?php" ??

Also, do you have a live version up where we can take a look to see what is happening?

It may be a configuration setting on your side. If the script that 1man provided is not working properly, something on your side is causing this to happen.

Do you have problems with any other scripts, or is it just this one in particular?

Reply With Quote
  #30  
Old September 29th, 2002, 09:08 PM
bigbear bigbear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 13 bigbear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Frank

Yeah, did replace "<?" with "<?php". Currently all other scripts work for me. I did place the old version on my server but it didn't work as well.

What configuration settings that might cause the problem? I'll put in a live version soon.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > devarticles.com rating system


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap