I am not a programmer or good at programming, just laying this out. I had a site coded for me, but the coder is not interested in further development. I need to rank images in the database by losses (kinda like votes) to views of an image. Originally, here is what was written for the code:
// get images
$result = $this->db->query("SELECT * FROM `ylyl_images` ORDER BY `loses` DESC LIMIT $start, 12");
That basically orders the images on the site by loses, and to paginate, it has the $start variable which is incremented by 12 for every “next page” click.
$result = $this->db->query("SELECT (`loses`/`views`) AS `ratio` FROM `ylyl_images` WHERE `views` > 150 ORDER BY `ratio` DESC LIMIT $start, 12");
That is what I came up with to order images based on ratio of loses to views, but the query doesn’t return anything. I tried replacing the $start variable with just 0, but it still doesn’t work.
Are you returning the right fields? In the code above, you Changed:
To…
Perhaps you need to return more fields. While I do not recommend ‘SELECT *’, you could do the following: