Page 1 of 1

create a website product comparision query using php mysql

Posted: Mon Mar 03, 2014 12:40 am
by mervdsz
Hi

I am trying to create a simple web comparision page using php-mysql.
The web pages contains products. I would like to provide viewers with the option to compare products. Atmost 4 products should be compared at same time.
Therefore i propose to place a small checkbox next to each product to see if 4 products are selected. Once 4 products are checked and compare button is clicked the results should display in pop-up window.

How do i write the query taking into consideration the products selected ???
how do i display the results from database onto website in a pop-up page ???

my products table is as follows:
product-id
product-name
price
quantity
stock

is there a better option to do it???

im a newbie to php and also mysql.I understand SQL having worked with ORACLE databases.
Can someone please help me. Give me some ideas to work around with.
Thanks in advance.

Re: create a website product comparision query using php mys

Posted: Mon Mar 03, 2014 7:14 am
by Celauran
Don't use pop up windows. Seriously.

That aside, what have you written so far and where are you running into trouble?

The simplest approach, I think would be to display your summary table with the checkboxes creating an array of IDs (ie. <input type="checkbox" name="product_ids[]" value="whatever">). You could use jQuery to disable checking boxes once four are checked if you like. Once the form is submitted, it's just a question of selecting the required columns from your products table where the ID is in the $_POST['product_ids'] array.