Reputation: 1
I am new to php. I have a site which have admin section.here i want admin to rate the products he is having and that rating should be stored in database.
I don't have any idea about this. Please anybody help me with some examples.
Upvotes: 0
Views: 540
Reputation: 22019
On a high level this is what you need to do.
In your database, add a new column:
ALTER TABLE `products` ADD COLUMN `star_rating` INT(1) NOT NULL DEFAULT 0;
Store a value that the user has clicked on, which will be either 0 to 5.
On output, you can output X stars with something such as the following:
<strong>Rating:</strong> <?php echo str_repeat('<img src="/star.png" alt="*" />', $row['star_rating']) ?>
.. where $row
is a mysql_fetch_assoc()
result from SELECT * FROM products
.
This is however all extremely basic and will be covered off in even the simplest of PHP/MySQL tutorials, you should really learn the language.
Upvotes: 2
Reputation: 2561
You can achieve this by many ways.. one way is you allow user to rate product and you can store ratings in one db column which entered by admin and then you can always print it.
Upvotes: 0