Rating Script - SELECT item, (totalrate / nrrates)
Posted: 24 Jan 2015, 20:40
Hi people,
I'm reasonably new to PDO and have just completed a GNU project for myself that uses your rating script, from: https://coursesweb.net/php-mysql/rating- ... jax-php_s2
And I'm stuck with this either returning multiple arrays or nonsensical data?
This is the db that I'm testing:
And I've kicked this around for hours and got nowhere?
Can you help me to sort it out so that is returns some sensible data that I can process as a list?
Thanks.
I'm reasonably new to PDO and have just completed a GNU project for myself that uses your rating script, from: https://coursesweb.net/php-mysql/rating- ... jax-php_s2
And I'm stuck with this either returning multiple arrays or nonsensical data?
This is the db that I'm testing:
Code: Select all
item totalrate nrrates
rt_35 3 1
rt_11 3 1
rt_25 4 1
rt_34 2 1
rt_33 4 1
rt_32 6 1
rt_17 5 1
rt_36 6 1
rt_12 4 1
rt_22 5 1
rt_24 4 1
rt_20 6 1
rt_11 3 1
rt_25 6 1
rt_33 6 1
rt_17 6 1
rt_32 6 1
rt_36 6 1
rt_35 7 1
Can you help me to sort it out so that is returns some sensible data that I can process as a list?
Thanks.
Code: Select all
$stmt = $database->prepare("SELECT `item`, (`totalrate` / `nrrates`) AS `rank` FROM `rtgitems` ORDER BY (`totalrate` / `nrrates`) DESC LIMIT 10");
$stmt->execute();
$row = $stmt->fetchAll();
{
foreach ($row as $row2)
{
$name2 = htmlEsc($row2['item']);
}
$name2 = str_replace("rt_", "", $name2);
echo ''.$name2.'';
}