This just screams AJAX, or at least at lot of HTML and some serious Javascript... I don't think anyone will just give you anything more than links to tutorials here, but I hope I'm proven wrong!
Good luck with your project :)
_Rade
Junior Poster in Training
55 posts since May 2010
Reputation Points: 12
Solved Threads: 7
Isn't that what $_session is for?
JRM
Practically a Master Poster
621 posts since Nov 2006
Reputation Points: 130
Solved Threads: 75
Ahh right after a page-load... the site you linked to was using ajax/js but you could achieve a similar effect using PHP and Javascript to automatically submit the form...
In this scenario you would have to have a bit of JavaScript to submit the form (every time a user selects a product for comparison) able to use $_POST[''] to grab that input's value by referencing the "name" of the input, and load a page which has added that product for comparison.
You could apply an "onchange" attribute when the user selects a product:
http://snippets.dzone.com/posts/show/785
Is that the sort of thing you mean?
_Rade
Junior Poster in Training
55 posts since May 2010
Reputation Points: 12
Solved Threads: 7
each checkbox is a column ID whech is collected from $_POST then stored in $_session for continued use until the selection is modified. The database would need to be accessed anyway, so PHP would work fine with a submit.
JRM
Practically a Master Poster
621 posts since Nov 2006
Reputation Points: 130
Solved Threads: 75
I have had success storing values in cookies. This was particularly useful when I had to transfer values between JavaScript and PHP.
Here is the code I wrote at the time. The context was that latitude and longitude values were being modified in a Google Maps application, and I wanted to be able to pick that up and store the value in a database. So I added a line geoCookies("lat","lon"); in the Google Maps javascript to store the values in a cookie every time the pointer on the map was moved.
Subsequently, my PHP code would read the cookie and write the value to the database record for that location.
geoCookies("lat","lon"); // write latitude & longitude to cookies
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
} // end function createCookie()
function geoCookies(lat,lon) {
// ~~~ WRITE LATITUDE/LONGITUDE TO COOKIE ~~~
// this function allows transfer of information from javascript to PHP
// (client-side script to server-side script) by storing the information
// in cookies.
// It uses session cookies; they won't be available in future sessions
// Once written, the cookies can be picked up by PHP to write to database
// alert("Lat: "+document.getElementById("lat").innerHTML+"\nLng: "+document.getElementById("lng").innerHTML);
createCookie("lat",document.getElementById("lat").innerHTML);
createCookie("lng",document.getElementById("lng").innerHTML);
} // end function geoCookies()
Then in PHP;
// retrieve latitude & longitude from cookies...
$latitude = $_COOKIE["lat"];
$longitude = $_COOKIE["lng"];
// ... and write them to the database
$latlon_sql = "UPDATE sac_map_locations SET latitude='$latitude',longitude='$longitude' WHERE id='".$_POST['id']."'";
mysql_query($latlon_sql)
or die(__LINE__.": Error updating Latitude/Longitude. Please advise webmaster: ".mysql_error());
I hope that's useful.
Rob
scaiferw
Junior Poster in Training
85 posts since May 2010
Reputation Points: 25
Solved Threads: 6