Hi everyone,
I'm new here and looking for some help, hope you don't mind. I'm using PHP and mysql.
I have a database that stores items. Let's just say for example I have:
ID, name, description, link, date added
Each item has a user rating. However, the user rating script I use doesn't store the value in the database. Instead, it saves it to a file on the server and opens it to read and get the value or to update it if a user makes a rating.
If I pull all the data from the database and loop it using a while loop, the rating script simply matches the ID with a file matching that ID, to display the user votes correctly.
My problem is, I offer the user various options to arrange the items in an order they wish, for example by name. I want to offer an option to arrange by user rating but because the values aren't stored in the database I can't just simply arrange it through my query, like I can with other options, example ORDER BY name.
I think what I need to do is add the values of the ratings to the array from the query and then arrange that array by 'user rating'. 😕
<-- previous code...
<?php
$result=mysql_query("SELECT * FROM entries") or die("Error, query failed");
while ($row = mysql_fetch_assoc($result))
{
echo <div>;
$rater_id=$row['ID']; // This matches the item id with a rating id to find the right file.
$rater_item_name=$row['name']; // This matches the item name with a rating name to find the right file.
include("rate/rater.inc.php"); // This is the user rating script that opens and closes the files for viewing or rating and also PRINTS the ratings.
echo </div>;
}
?>
The above cut-down code works fine like I said. The rating values are stored in
$rater_ratings
How do I add $rater_ratings to the $row array and then arrange the array by $rater_ratings? Or rather is it even possible?
But surely everything is possible... lol That's my attitude anyway lol
I hope I explained clearly, sorry if I didn't I'm rather new to this! :eek:
Any help appreciated! 😉
Craig.