Page 1 of 1
Product Pop-up.
Posted: Wed Dec 29, 2004 4:51 pm
by conscience
I've got a PHP-only shopping cart system, and am trying to integrate a function where the user clicks on a product image and a window pops with back/next links and a slideshow above. Currently the URLs of the images are stored in a MySQL database column and can be accessed with $row["itemPic"].
I am very un-savvy in regards to JScript. How could I implement this functionality?
Posted: Wed Dec 29, 2004 6:43 pm
by feyd
[devnet]+window +open[/devnet]
[google]+window.open[/google]

Posted: Thu Dec 30, 2004 12:03 pm
by conscience
Right, so I've got a JScript built with all the functionality I want. It pulls the URLs from an array called 'Picture'. How do I populate the array with $row["itemPic"] values from PHP? If the function is called from the middle of the PHP page where this is already defined from the MySQL query, can I just do a FOREACH loop or something?
Posted: Thu Dec 30, 2004 12:54 pm
by conscience
I'm now echoing the Javascript through PHP.
Would this work? If there are multiple URL values in the "itemPic" column in the MySQL database, is Count() going to lump them together as one value, or as many?
Code: Select all
$pics = $rowї"itemPic"];
$num = count($pics);
for($i = 0; $i < $num; $i++) {
foreach ($pics as $pic) {
echo "Pictureї" . $i . "] = '" . $pic . "';"; }
}
Posted: Fri Dec 31, 2004 3:26 am
by Chris Corbyn
If your counting the array you create then count() will count the values so in ohter words you will get the correct number.
You could also use sizeof()
EDIT: To get the the number of rows in your database use mysql_num_rows($mysql_result); where $mysql_result is the output of your query.
Posted: Wed Jan 05, 2005 3:13 pm
by conscience
Great. Now.. what do I need to do to make the $pics variable accept a $_GET variable from the previous page? Do I need to make each poppable item its own form?
Tried searching for this sort of thing but I keep getting no results when searching for "$_GET*" or "GET".
Posted: Wed Jan 05, 2005 3:40 pm
by feyd
the $_GET variables are set when you go to a url like this:
http://imadork.com/page.php?something=nothing
where $_GET['something'] is set to 'nothing'
Posted: Wed Jan 05, 2005 3:56 pm
by conscience
So in regards to the parent page, I need hidden form elements echoing the item names, and then pass the $_GET values as arguments to the JS pop-up function? Content of the parent page is dynamically generated from a database, so I can't just arbitrarily toss out input names and values.
Posted: Wed Jan 05, 2005 4:02 pm
by feyd
true, but they are easily generated. All you need is some unique identifier for the popup to lookup the details of that item. It doesn't require a form, just a link, which you can generate along with the rest of the content.
Posted: Wed Jan 05, 2005 4:11 pm
by conscience
Unique identifier: Like the item's name or something?
Can you cite an example, please? My brain isn't entirely understanding..
Posted: Wed Jan 05, 2005 4:23 pm
by feyd
like every item in a database typically has an id associated with it. Kinda like a product sku, it's unique among your inventory.
Posted: Wed Jan 05, 2005 4:44 pm
by conscience
I see. How would I use this syntactically?