Hi, what is the php code to display a particular product and its price for instance I would like to display products 1 to 10 (along with there prices and names) on one page and 10 to 20 on another page
I already tried this from another post but it says "access is not allowed. please go to membership information page" What I want to do is to be able to display any product with its price even if user is not logged in
yes but i dont want it on my signup page. I want my sign up page to be clean. I want to make my own products page where I put a picture of the product, and under it I have code that will get the name of the product and the price.
I guess in theory (as in this has not been tested), you could try including a couple of aMember files in an otherwise clean php page (probably config.inc.php and mysql.inc.php?) to create a database connection and then call the relevant functions ( get_products_list(), get_product($product_id) ) and display the arrays. I suspect you would need to have some PHP skills including a good understanding of error messages and some patience... Any help? ian
I tried this: <?php include "amember/config.inc.php"; $products = $db->get_product(22); print $products.title; print $p.title; ?> but all it returned was Arraytitletitle
Ok, looks slightly promising, try this: PHP: <?php include "amember/config.inc.php"; $products = $db->get_product(22); print_r($products); ?> If the database bit is working ok then $products should be an array of all the properties of product id 22. print_r is a general PHP command that will spit out the contents of that array. Let us know what happens. Ian
Ok it works but it isnt exactly what I want. all i need is price and title. I really dont want the other fields. this is what it returns: Array ( [product_id] => 22 [title] => Lili [description] => Lili Photo Set [price] => 10.00 [expire_days] => 14 => /pimages/Lili/Lili.zip [add_url...ray ( [0] => ACTIVE-1 ) [prevent_if_other] =>
PHP: <?phpinclude "amember/config.inc.php";$p = $db->get_product(22);print 'title=' . $p['title'] . '<br>';print 'price=' . $p['price'] . '<br>';?>
@heckubiss, the nature of a forum and because I don't know your level of PHP experience means I'm going one small step at a time. Alex has provided the next step above for a specific product. To generate a list of products, do a print_r() on the result of a get_products_list() query - this will probably produce an array of arrays - put it on this thread and someone can generate the code you need to display the list. Ian
Actually all I need is the price. Now I am trying to make a function so I dont have to have the above php code for every product I have. I just want to say show_price(22) and have it output the price. So for example I have a php file that looks like this <?php session_start(); ?> <html> <head> </head> <body > </body> </html> Do I have to wrap the whole file in <?php ?>
Never mind I figured it out. <?php include "amember/config.inc.php"; function show_price($prod) { global $db; $p = $db->get_product($prod); print $p['price'] . '<br>'; } ?> and when I want to find the price of the product I do <?php show_price(22); ?> for product 22 etc Thank you Ianh and Alex for your help. Now when I change my prices in aMember, they will automatically be reflected on my page without haveing to manually change them all