Jump to content

[SOLVED] TOP 100 of PHOTOS, any IDEA?


crashmaster

Recommended Posts

Hi there,

I have now any idea how to create TOP 100 of users FOTO.

 

I have a user system. Every user can add to his profile fotos, and any another user can rate it.

 

For every foto I have in database clumns : rating, count_rates (how many people rated this foto)

 

Does anybody have idea how to speculate with this data ?

 

For example I have 1 idea, but I dont know how to improve it in DB level.

 

Idea:

 

to do mysql query with conditions : select user with the most count of rates and with best rating..But how to do it in mysql_query ??

Link to comment
Share on other sites

I don't understand what your actually trying to do but

 

<?php

$result = mysql_query("SELECT * FROM rating_table ORDER BY rating_column DESC LIMIT 100")
             or die(mysql_error());

    while($row = mysql_fetch_array($result)){
         
         $userid         = $row['user_id']; // Id of the users in which the photo was rated
         $users          = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE user_id = '$userid'"));
         
            echo $users['username'] . "<br>"; // print results

}
?>

Link to comment
Share on other sites

I do my ratings based on users so this is what I do

<?php
$q = "Select PhotoID  from `Photo_ratings` Where count(rating) > `50` ORDER BY AVG(rating) LIMIT 1000";
$r = mysql_query($q) or die(mysql_error());
if(mysql_num_rows($r) >0){
while($row = mysql_fetch_array($r)){
  $top100[] = "PhotoID = '".$row[0]."'";
}
}
$top100 = implode(" || ",$top100);
$q2 = "Select * from `photos` Where ".$top100;
$r2 = mysql_query($q2) or die(mysql_error());
if(mysql_num_rows($r2)>0){
while($row2 = mysql_fetch_assoc($r2)){
//Display top100
}
}
?>

 

Simple and works if each users rating is its own row

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.