Page 1 of 1

Rating System, Display Votes

Posted: Sun Jul 31, 2011 12:53 pm
by wizzuriz
Hello again.

I´ll just like to say thanks for the nice work your doing and ask a question.

What If I like to show the votes on each item?

I don´t really know how to add the product_votes to the array and show it.

Please let me know if there is a easy way to get the amount of votes next to or under the item name.

Best regards
Wizzuriz

Re: Very great tutorial

Posted: Sun Jul 31, 2011 2:18 pm
by jacek
Which tutorial are you referring to ?

Also, can you explain what you mean a bit more ?

EDIT: Actually I think I know what you mean, you just need to add the number of votes tot he column list in the SELECT part of the query.

Re: Rating System, Display Votes

Posted: Sun Jul 31, 2011 4:59 pm
by wizzuriz
Hello Again. :)

This is the code from vore & rating system.

product.inc.php
function fetch_products(){
    $sql = "SELECT
                `product_id`,
                `product_name`
            FROM `products`
            ORDER BY `product_votes` DESC";
    
    $result = mysql_query($sql);
    
    $products = array();
    
    $level = array();
    
    while (($row = mysql_fetch_assoc($result)) !== false){
        $products[$row['product_id']] = $row['product_name'];
    
    }
    return $products;
}
becomes =
function fetch_products(){
    $sql = "SELECT
                `product_id`,
                `product_name`,
                `product_votes`
            FROM `products`
            ORDER BY `product_votes` DESC";
    
    $result = mysql_query($sql);
    
    $products = array();
    
    $level = array();
    // how will I add it here in the array ? 
    while (($row = mysql_fetch_assoc($result)) !== false){
        $products[$row['product_id']] = $row['product_name'];
    
    }
    return $products;
}
how will I add it on the list.php when its in the array.

Thanks for your quick replay.

Regards
Wizzuriz

Re: Rating System, Display Votes

Posted: Sun Jul 31, 2011 8:32 pm
by jacek
on list.php you will be able to do
echo $item['product_votes'];
Which will the total number of votes that product has.

Re: Rating System, Display Votes

Posted: Mon Aug 01, 2011 7:20 am
by wizzuriz
Thanks, I will try that.

Should I add it in the while loop? if then how?
// AND ['product_votes'] ?
while (($row = mysql_fetch_assoc($result)) !== false){
        $products[$row['product_id']] = $row['product_name'];
A other question is, are you planing to make a online class room?

I believe that many would like a online class, one where we could ask question and have hands on help. There could be a small fee for each class and we can vote each week on what to talk and work with.

Just a ideer.

Ones again thanks I will get back to you on how that vote item. :)

Regards
Wizzuriz

Re: Rating System, Display Votes

Posted: Mon Aug 01, 2011 12:03 pm
by jacek
wizzuriz wrote:Should I add it in the while loop? if then how?
// AND ['product_votes'] ?
Ah yeah you will need to do somethign like
    while (($row = mysql_fetch_assoc($result)) !== FALSE){
            $products[$row['product_id']] = array(
                'name' => $row['product_name'],
                'votes' => $row['product_votes'],
            );
wizzuriz wrote:A other question is, are you planing to make a online class room?

I believe that many would like a online class, one where we could ask question and have hands on help. There could be a small fee for each class and we can vote each week on what to talk and work with.
Possibly, YouTube partners can live stream on their channels so I might do that at some point not that soon. It would obviously be free.