 | |  |
 |

Djulia
User
Feb 13, 2008, 7:25 AM
Post #1 of 12
(901 views)
Shortcut
|
|
Products Page and Paypal
|
Can't Post
|
|
Hello, I would like to create a Array, but I encounter a problem. I have a section Shop and I would like to obtain the list of the products in a table (Array). Here the structure of my section : Shop : Product1 : item_name, item_number, amount, ... Product2 : item_name, item_number, amount, ... Shop == Section Name ProductXX == Page item_xx == Field Now, I would like to obtain a page (catolog.php) with the articles in tables (Array) : <?PHP $items = array( array( 'item_name' => 'Product1', 'item_number' => 'sw01', 'amount' => '30.50', 'on0' => 'Delivery', 'os0' => 'Instant download', 'on1' => 'Option Name', 'os1' => 'Option Value', 'file' => '/home/domain/files/test_software.zip', ), array( 'item_name' => 'Product2', 'item_number' => 'song02', 'amount' => '0.50', 'on0' => 'Delivery', 'os0' => 'Instant download', 'on1' => 'Format', 'os1' => 'MP3', 'file' => '/home/domain/file.mp3', ), ); ?> I do not see how to obtain this. Thank you for your assistance. Djulia
(This post was edited by Djulia on Feb 16, 2008, 3:18 PM)
|
|
|  |
 |

Dave
Staff
/ Moderator

Feb 13, 2008, 8:57 AM
Post #2 of 12
(886 views)
Shortcut
|
So this is for some custom PHP coding your doing? I think if you take a look at $listRows, it's in the exact format you're looking for. Try this:
<xmp><?php print_r($listRows); ?></xmp> Does that help? Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

Djulia
User
Feb 14, 2008, 3:04 AM
Post #3 of 12
(872 views)
Shortcut
|
Thank you Dave for your assistance. In fact, I try to use a Cart-based system to process orders Paypal. The system gives the possibility to use dynamic PHP code to create the list of items from a database. Items in the catalog.php file are stored in a PHP array format called $items which is an array of associative arrays. http://www.stellarwebsolutions.com/en/products.php#evendorpro Also, your solution is correct. But I still have a problem and I do not know if the origin is the table created or script. I await an answer of the editor. If not, it is possible to obtain a array with only some entries ? Currently, I obtain : Array ( [0] => Array ( [num] => 1 [item_number] => sw01 [amount] => 30 [item_name] => Test Software Widget [_link] => /paypal/productsPage.php/1/ )... I could obtain : Array ( [0] => Array ( [item_number] => sw01 [amount] => 30 [item_name] => Test Software Widget )... It is perhaps the origin of my problem. Thank you for your answer. Djulia
|
|
|  |
 |

Djulia
User
Feb 15, 2008, 5:24 AM
Post #4 of 12
(836 views)
Shortcut
|
Hi Dave, With the assistance of the editor (and you), we found the solution. The script (and others) works perfectly with your CMS. That reinforces my opinion on the many possibilities of your CMS. Thank at you and your team. Djulia
|
|
|  |
 |

Djulia
User
Feb 21, 2008, 4:58 AM
Post #5 of 12
(749 views)
Shortcut
|
Hi Dave, I have a new challenge for CMS Builder. I would like to add several elements at the end of my table (array) with the function array_push. I tested : <?php require_once "/home/../lib/viewer_functions.php"; $options = array_push(); $options['tableName'] = 'products'; ... ?> But that gives an error message : Warning: Wrong parameter count for array_push() in /home/../myPage.php on line xx An example of what I must obtain : section 1 <?PHP $items = array ( array ( 'item_name' => 'Cotton T-Shirt', 'item_number' => 'on1', 'amount' => '9.50', ));?> section 2 <?PHP array_push ($items, array ( 'item_name' => 'Shirt', 'item_number' => 'os8', 'amount' => '19.99', )); ?> where array == section 1 and array_push == section 2 ... You think that there is a solution ? Thank you for your assistance. Djulia
(This post was edited by Djulia on Feb 21, 2008, 5:07 AM)
|
|
|  |
 |

Dave
Staff
/ Moderator

Feb 21, 2008, 1:48 PM
Post #6 of 12
(718 views)
Shortcut
|
Hi Djulia, I think you probably want to add those to $listRows, or some other variable and not $options? Is that right? If so you'd do it after the line where you define $listRows but before you list it. Does that make sense? Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

Djulia
User
Feb 22, 2008, 2:56 AM
Post #7 of 12
(705 views)
Shortcut
|
Thank you Dave for your answer. In fact, I am lost a little. I tested in catalog.php : <?php require_once "/home/../lib/viewer_functions.php"; $options = array(); $options['tableName'] = 'products1'; $options['perPage'] = '9999'; $options['where'] = '1'; list($items1, $listDetails) = getListRows($options); ?> <?php require_once "/home/../lib/viewer_functions.php"; $options = array(); $options['tableName'] = 'products2'; $options['perPage'] = '9999'; $options['where'] = '1'; list($items2, $listDetails) = getListRows($options); ?> <?php $stack = array_push($items1, $items2); ?> <xmp><?php print_r($stack); ?></xmp> But, that gives the correct number of the recordings, but does not give the table. You have an idea ? Thank you for your assistance. Djulia
(This post was edited by Djulia on Feb 22, 2008, 2:57 AM)
|
|
|  |
 |

Djulia
User
Feb 22, 2008, 4:03 AM
Post #8 of 12
(701 views)
Shortcut
|
I obtained the table, but that does not correspond to my need. <?php $stack = array_push($items1, $items2); $items = $items1; ?> The result gives a new table in the table. Array ( [0] => Array ( [num] => 1 [item_number] => R02 [amount] => 29.99 ... ) [1] => Array ( [num] => 2 [item_number] => R01 [amount] => 19.99 ... ) ... [4] => Array ( [0] => Array ( [num] => 1 [item_number] => P1 [item_name] => P1 [amount] => 10 ... ) ) ) You think that it is possible to have only one table ? Array ( [0] => Array ( [num] => 1 [item_number] => R02 [amount] => 29.99 ... ) [1] => Array ( [num] => 2 [item_number] => R01 [amount] => 19.99 ... ) ... [4] => Array ( [num] => 1 [item_number] => P1 [item_name] => P1 [amount] => 10 ... ) ) Thank you for your assistance. Djulia
|
|
|  |
 |

Dave
Staff
/ Moderator

Feb 22, 2008, 10:01 AM
Post #9 of 12
(694 views)
Shortcut
|
Hi Djulia, array_push() pushes a reference (or pointer) to $items2 on the end of $item1. Try array_merge(). I think that will do what you want.
<?php $stack = array_merge($items1, $items2); ?> See these links for more details: http://www.php.net/array_merge http://www.php.net/array_push Hope that helps! Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

Djulia
User
Feb 23, 2008, 8:29 AM
Post #10 of 12
(680 views)
Shortcut
|
Thank you Dave for your assistance, Your solution is correct, but it does not function with script. In fact, the script functions with 2 catalog files : // include the product catalog file in cart.php require_once ('catalog1.php'); require_once ('catalog2.php'); The array (items, declared in catalog1.php) is built with these 2 files and the function array_push used in the file catalog2.php. The code that I currently use in catalog2.php is : <?php require_once "/home/.../lib/viewer_functions.php"; $options['tableName'] = 'products'; $options['perPage'] = '9999'; $options['where'] = '1'; list($pr) = getListRows($options); array_push($items, $pr); ?> And, it gives me 2 arrays : <?PHP array_push ($items, array( array( 'item_name' => 'Product1', 'item_number' => 'pr_01', 'amount' => '19.99', ) )); ?> But, I only need 1 array : <?PHP array_push ($items, array( 'item_name' => 'Product1', 'item_number' => 'pr_01', 'amount' => '19.99', ) ); ?> I tested : <?php require_once "/home/.../lib/viewer_functions.php"; $options['tableName'] = 'products'; $options['perPage'] = '9999'; $options['where'] = '1'; list($pr_) = getListRows($options); array_push($items, $options); ?> That functions with the script, but does not give the good values. It would be possible to use something like this : array_push($items, getListRows($options)); You think that there is a solution ? Thanks, Djulia
(This post was edited by Djulia on Feb 23, 2008, 9:01 AM)
|
|
|  |
 |

Djulia
User
Feb 23, 2008, 12:02 PM
Post #11 of 12
(668 views)
Shortcut
|
Hi Dave, I think that I found the solution : <?php require_once "/home/.../lib/viewer_functions.php"; $options['tableName'] = 'products'; $options['perPage'] = '9999'; $options['where'] = '1'; list($pr_) = getListRows($options); $items = array_merge($items, $pr_); ?> Your track was the good one, thank you. Djulia
(This post was edited by Djulia on Feb 23, 2008, 12:17 PM)
|
|
|  |
 |

Dave
Staff
/ Moderator

Feb 25, 2008, 1:47 PM
Post #12 of 12
(600 views)
Shortcut
|
Glad to hear it's working. You seem to be doing some pretty neat things with CMS Builder! :) Dave Edis - Senior Developer interactivetools.com
|
|
|  |
|