Jump to content

Help me build rating query to add rating


co.ador

Recommended Posts

looking for an sql injection where I can display the total sum of each star that a item has been rated by users to better explain it I will post a pictures so you can see. I will also post a database dump so you guys have an idea of how the database is built.

 

shoeshtmal.gif

 

 

database dump

 

--

-- Database: `menu`

--

 

-- --------------------------------------------------------

 

--

-- Table structure for table `rating`

--

 

CREATE TABLE IF NOT EXISTS `rating` (

  `item_name` varchar(100) NOT NULL,

  `ip_address` varchar(15) NOT NULL,

  `rating` tinyint(1) NOT NULL,

  `date_rated` date NOT NULL,

  PRIMARY KEY (`item_name`,`ip_address`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

 

The rating field is a number from 1 to 5 is recorded in there and it will vary according to the user rate. and that's the field I want to retrieve and sum all the 1 rating the 2 rating 3 ratings of item-name "X"

Ok mysql numbers of rows

 

 

"SELECT rating FROM rating WHERE rating= 1";

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

if (mysql_num_rows($result) > 0) { sum rating}

 

 

 

"SELECT rating FROM rating WHERE rating= 2";

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

if (mysql_num_rows($result) > 0) { sum rating}

 

 

$query ="SELECT rating FROM rating WHERE rating= 3";

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

if (mysql_num_rows($result) > 0) { sum rating}

 

 

I just throwing something, Please explain anything you do here guys thank you...

 

 

I am just doing something crazy here so you can

 

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.