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"

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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