Rating System, Display Votes

Post here is you are having problems with any of the tutorials.
Post Reply
wizzuriz
Posts: 53
Joined: Mon Jul 25, 2011 4:22 pm

Rating System, Display Votes

Post 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
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Very great tutorial

Post 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.
Image
wizzuriz
Posts: 53
Joined: Mon Jul 25, 2011 4:22 pm

Re: Rating System, Display Votes

Post 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
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Rating System, Display Votes

Post 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.
Image
wizzuriz
Posts: 53
Joined: Mon Jul 25, 2011 4:22 pm

Re: Rating System, Display Votes

Post 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
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Rating System, Display Votes

Post 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.
Image
Post Reply