PHP - How To Make A Dynamic Product Detail Page?
I have a product page which populates all my products in one page. I have also a detail page which gives details on a product which i wanted to know. My problem is when I am going to click on the product that I want the detail page shows incorrect product details. I just want one detail product page so that it will be easy to edit the page in the future. I am asking an Idea on how to make one detail page in all of my products.. thanks... Similar TutorialsHi there, I'm trying to get the full Product Name in the <title> of each of the product pages - I can't seem to figure out what to put in the product_info.php... I've tried a few different options but I'm not great with php Here's what I have currently but it creates errors... <script language="javascript"><!-- document.write('<title><?php echo TITLE; ?> : <?php echo $product_info['products_name']; ?> </title>'); //--></script> Hope someone can help - thanks so much! I want to create a master-detail page using PHP. Rather than getting data from a MYSQL database, I want to get the data from an associative array. Is this possible? Please someone show me the way forward. Please help. I have a website here [redacted] and it is an affiliate website where I just find products and promote them. All I have to do is give product a title, affiliate url, the description, an image and a price. I am trying to make the product description area hold more text than it does now, because at the moment in the admin side of my website it says "product description 275 max characters" That is really a short sentence. Can anyone please help me I have no php skills but really wish I did, if you need more info I will be happy to share anything I need to. Edited October 27, 2019 by requinixremoved link Folks, I need help (Php code ) to generate a Dynamic Text on a Base Image. What i want to do is, to make this Image as header on my Site and to make this Header Specific to a Site, i want to Add the Domain Name on the Lower Left of the Image. Got the Idea? Here is the Image link: Quote http://img27.imageshack.us/i/shoppingheader1.jpg/ PHP Variable that holds the Domain name is: $domain All i need the Dynamic PHP Codes that i can put on all my sites to generate this Text on Image (Header) Dynamically... May Anyone Help me with this Please? Cheers Natasha T. Hi. This question is building off of things you all helped me with earlier in my other two threads. (I go no sleep last night, so sorry if my thinking is a bit off!) Now that I know how to create a gallery page - as far as HTML goes - to display a listing of free add-on items you get when you subscribe, I need to extend those concepts to my next project. I need to create a product catalog page for my e-commerce site. (Not sure if there is a better name?) This is the page you would see if you went to an e-commerce site and started shopping. At the top of the page would be my company mast. And beneath that, on the left side of the screen would be a menu listing different areas of my online store. And to the right, would be the area where you see the actual products. (And I would be using the same techniques to display items on the right hand side as I did in my earlier gallery. So here is where I could use some hep with the logic of this page... Let's say my website is located at www.mystore.com And in the left menu bar, I have these categories: Music, TV Shows, Movies, Gear And in the right pane I want to display items for the chosen section. So if you chose "Music", I am thinking the hyperlink behind it might read; www.mystore.com/music/ with a mod_rewrite to www.mystore.com?category=music And then I would have PHP code that would fire when the page is reloaded to www.mystore.com?category=music and it would query MySL and display all music related products in the right pane. (Note: It is understood I am only using HTML and PHP with no Javascript.) How does the above approach sound?
Hello. I just created a product gallery containing thumbnails of items that I will be selling. When a user click on on of the thumbnails, I want a product details page to appear with more details about the chosen product Could use some feedback if I am going about things the right way... Step 1: User goes to my gallery located he www.mysite.com/store/product-gallery.php Step 2: System displays a page of thumbnails representing items that I am selling. Step 3: User click on a given thumbnail which is a hyperlink to: www.mysite.com/store/products/4571 Step 4: System rewrites the URL as such: www.mysite.com/store/products.php?sku=4571 Step 5: System queries MySQL and retrieves record for sku 4571 Step 6: System displays product details for the chosen item in Step 3 which is sku 4571
How does that sound?
Hi, I have successfully implemented a master details page with the results aligned in columns linking to a details page. I wish to maintain the recordID passed from the master details page and make the dynamic text, which reads Shade A tree that is capable of..... in the attached screen shot a link to another details page referencing the same recordID. The detailspage2.php would look the same as the screenshot except the Shade text and description below will be highlighted, which I can do, there will be a new image and a new image description. All other dynmaic elements on the page will remain the same. I tried to simply save as my detailspage.php to detailspage2.php and create a link to detailspage2.php. It linked to detailspage2.php but none of the record info showed up in their respective table cells. I have all the names desc's, images, etc setup in a table in my database. Please let me know what code and other info you need to help me out with this procedure. Thanks. Hi,
I have this snippet in my page:
<?php echo $EM_Booking->get_price(true) * $EM_Booking->get_spaces(); ?>The page executes with no hitches except the price is not multiplied by the spaces. I get and echo of "0". I'm new to this. Any help would be greatly appreciated and thanks! I would like to customize my product-list page to display all my products in a grid with an ADD TO CART option for each product. That means i have two ADD TO CART button on the site, in productDetail.php there is a ADD TO CART button original from the tutorial, i need customize another ADD TO CART button on productList.php. Does anyone know how to accomplish this customization? . Please help because I am stuck with the coding for 3weeks Tutorial site: http://www.phpwebcommerce.com/plaincart/index.php productDetail.php: Code: [Select] <?php if (!defined('WEB_ROOT')) { exit; } $product = getProductDetail($pdId, $catId); // we have $pd_name, $pd_price, $pd_description, $pd_image, $cart_url extract($product); ?> <table width="100%" border="0" cellspacing="0" cellpadding="10"> <tr> <td align="center"><img src="<?php echo $pd_image; ?>" border="0" alt="<?php echo $pd_name; ?>" width="230" height="170"></td> <td valign="middle"> <strong><?php echo $pd_name; ?></strong><br> Price : <?php echo displayAmount($pd_price); ?><br> <?php // if we still have this product in stock // show the 'Add to cart' button if ($pd_qty > 0) { ?> <input type="button" name="btnAddToCart" value="Add To Cart >" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton"> <?php } else { echo 'Out Of Stock'; } ?> </td> </tr> <tr align="left"> <td colspan="2"><?php echo $pd_description; ?></td> </tr> </table> productList.php: Code: [Select] <?php if (!defined('WEB_ROOT')) { exit; } $productsPerRow = 2; $productsPerPage = 8; //$productList = getProductList($catId); $children = array_merge(array($catId), getChildCategories(NULL, $catId)); $children = ' (' . implode(', ', $children) . ')'; $sql = "SELECT pd_id, pd_name, pd_price, pd_thumbnail, pd_qty, c.cat_id FROM tbl_product pd, tbl_category c WHERE pd.cat_id = c.cat_id AND pd.cat_id IN $children ORDER BY pd_name"; $result = dbQuery(getPagingQuery($sql, $productsPerPage)); $pagingLink = getPagingLink($sql, $productsPerPage, "c=$catId"); $numProduct = dbNumRows($result); // the product images are arranged in a table. to make sure // each image gets equal space set the cell width here $columnWidth = (int)(100 / $productsPerRow); ?> <table width="100%" border="0" cellspacing="0" cellpadding="20"> <?php if ($numProduct > 0 ) { $i = 0; while ($row = dbFetchAssoc($result)) { extract($row); if ($pd_thumbnail) { $pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail; } else { $pd_thumbnail = WEB_ROOT . 'images/no-image-small.png'; } if ($i % $productsPerRow == 0) { echo '<tr>'; } // format how we display the price $pd_price = displayAmount($pd_price); echo "<td width=\"$columnWidth%\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?c=$catId&p=$pd_id" . "\"><img src=\"$pd_thumbnail\" border=\"0\" width=\"230\" height=\"170\"><br>$pd_name</a><br>Price : $pd_price<br>"; // format display add to cart echo "<input type=\"button\" name=\"btnAddToCart\" value=\"Add To Cart >\" onClick=\"window.location.href='<?php echo $cart_url;?>';\" >"; // if the product is no longer in stock, tell the customer if ($pd_qty <= 0) { echo "<br>Out Of Stock"; } echo "</td>\r\n"; if ($i % $productsPerRow == $productsPerRow - 1) { echo '</tr>'; } $i += 1; } if ($i % $productsPerRow > 0) { echo '<td colspan="' . ($productsPerRow - ($i % $productsPerRow)) . '"> </td>'; } } else { ?> <tr><td width="100%" align="center" valign="center">No products in this category</td></tr> <?php } ?> </table> <p align="center"><?php echo $pagingLink; ?></p> Product-functions.php: Code: [Select] <?php require_once 'config.php'; /********************************************************* * PRODUCT FUNCTIONS **********************************************************/ /* Get detail information of a product */ function getProductDetail($pdId, $catId) { $_SESSION['shoppingReturnUrl'] = $_SERVER['REQUEST_URI']; // get the product information from database $sql = "SELECT pd_name, pd_description, pd_price, pd_image, pd_qty FROM tbl_product WHERE pd_id = $pdId"; $result = dbQuery($sql); $row = dbFetchAssoc($result); extract($row); $row['pd_description'] = nl2br($row['pd_description']); if ($row['pd_image']) { $row['pd_image'] = WEB_ROOT . 'images/product/' . $row['pd_image']; } else { $row['pd_image'] = WEB_ROOT . 'images/no-image-large.png'; } $row['cart_url'] = "cart.php?action=add&p=$pdId"; return $row; } ?> any help will be greatly appreciated This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=343748.0 Hello. I want to create some variables dynamically. I have this so far: for($i = 1; $i <= 4 ; $i++){ $a = 'member' . $i; $$a = array(); } Does that give me this 4 arrays?: $member1, $member2, $member3 and $member4? Of course I want some process inside of the loop, but that would depend on the variables. Would that work? thanks! Hello everyone. This is my first post, so be nice! I am building a website that will have a lot of content, similar to a newspaper. I have some pretty good HTML/CSS pages written, but the problem is that I need a way to make things more dynamic. One of my templates has a Header, Left Column, Middle Column, Right Column, and Footer. Everything stays the same from page to page except for the Middle Column (which holds each article). As it stands now, if I had 12 articles, I would have to have 12 nearly duplicate HTML pages which isn't good! I started studying PHP a while ago, but put that on hold to learn HTML/CSS, so I've kinda forgotten how PHP can help me out! Can someone help me figure out how to use PHP to my benefit? Thanks, Debbie since many do not know the term sticky = when a form is submitted, the data contained is not deleted but instead last checked data will be shown. I have some dynamically generated checkboxes from the database. I tried the below code to make them sticky but they are simply preselected in stead of becoming sticky. What am I doing wrong? <?php $sql2 = "SELECT relation FROM table_rel_info"; $result2 = @mysqli_query($dbc, $sql2); while($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC)) { echo "<label>" . $row2['relation'] . "</label>"; echo "<input class='box' type='checkbox' value=1"; ?> <?php if (isset($row2['relation'])) { echo 'checked="checked"';}?> <?php echo "'/>" . "<br />"; } ?> I am an extremly novice at this php stuff. I have a file that displays a vehicle listing based on a xml feed. I am trying to add a link to another detail page by clicking on the words Full Detail (bolded below in the code) and send me to another page (index.php?option=com_content&view=article&id=6 (joomla)), the item detail page is based on the vehicle id and has the vehicle details show up. the detail page is also a xml file with the item info. I assume I have to use the <a href.... but how do I add the Id of the vehicle. Do I use a .($_Get['vehicleid']). Follow me? Partial Listing of Vehciles Code: [Select] $doc = new DOMDocument(); $doc->loadXML($output); $vehicles = $doc->getElementsByTagName("vehicle"); //print_r($xmlarray); $results = print_r($xmlarray, true); echo $results; foreach ($vehicles as $vehicle) { $vehicleIDs = $vehicle->getElementsByTagName("vehicleID"); $vehicleID = $vehicleIDs->item(0)->nodeValue; $years = $vehicle->getElementsByTagName("year"); $year = $years->item(0)->nodeValue; $makes = $vehicle->getElementsByTagName("make"); $make = $makes->item(0)->nodeValue; $models = $vehicle->getElementsByTagName("model"); $model = $models->item(0)->nodeValue; $prices = $vehicle->getElementsByTagName("price"); $price = $prices->item(0)->nodeValue; $modelExts = $vehicle->getElementsByTagName("modelExt"); $modelExt = $modelExts->item(0)->nodeValue; $conditions = $vehicle->getElementsByTagName("condition"); $condition = $conditions->item(0)->nodeValue; $auxPhotoss = $vehicle->getElementsByTagName("auxPhotos"); $auxPhotos = $auxPhotoss->item(0)->nodeValue; $transmissions = $vehicle->getElementsByTagName("transmission"); $transmission = $transmissions->item(0)->nodeValue; $cylinderss = $vehicle->getElementsByTagName("cylinders"); $cylinders = $cylinderss->item(0)->nodeValue; $fueltypes = $vehicle->getElementsByTagName("fueltype"); $fueltype = $fueltypes->item(0)->nodeValue; $doorss = $vehicle->getElementsByTagName("doors"); $doors = $doorss->item(0)->nodeValue; $financings = $vehicle->getElementsByTagName("financing"); $financing = $financings->item(0)->nodeValue; $paymentFrequencys = $vehicle->getElementsByTagName("paymentFrequency"); $paymentFrequency = $paymentFrequencys->item(0)->nodeValue; $kilometerss = $vehicle->getElementsByTagName("kilometers"); $kilometers = $kilometerss->item(0)->nodeValue; $imgSrcs = $vehicle->getElementsByTagName("imgSrc"); $imgSrc = $imgSrcs->item(0)->nodeValue; $formattedprice = sprintf("%01.2f", $price); $price_currency = number_format($price, 2, ".", ","); if ($price_currency == 0) { $price_currency = "CONTACT DEALER"; } $featuress = $vehicle->getElementsByTagName("features"); $features = $featuress->item(0)->childNodes; $featureCount = $features->length; $i = 0; $featurestring = ""; while ($i < $featureCount) { $i++; $featureA[$i] = $features->item($i - 1)->nodeValue; $featurestring .= ($i % 2 == 0 ? $featureA[$i] . ", " : ""); } echo "<table style=background-color: rgb(246, 246, 246)text-align: left width: 900px height: 100px\n"; echo " border=0 cellpadding=2 cellspacing=2>\n"; echo " <tbody>\n"; echo " <tr>\n"; echo " <td\n"; echo " style=background-color: black font-family: Helvetica,Arial,sans-serif><small><span\n"; echo " style=color: yellow><span style=font-weight: bold>Vehicle ID:</span>\n"; echo " $vehicleID</span></small></td>\n"; echo " <td\n"; echo " style=background-color: rgb(255, 204, 0) font-family: Helvetica,Arial,sans-serif width: 147px><small>Year:\n"; echo " $year</small></td>\n"; echo " <td\n"; echo " style=background-color: rgb(255, 204, 0) font-family: Helvetica,Arial,sans-serif width: 109px><small>Make:\n"; echo " $make</small></td>\n"; echo " <td\n"; echo " style=background-color: rgb(255, 204, 0) font-family: Helvetica,Arial,sans-serif width: 141px><small>Model:\n"; echo " $model</small></td>\n"; echo " <td\n"; echo " style=background-color: black font-family: Helvetica,Arial,sans-serif width: 147px><small><span\n"; echo " style=color: rgb(255, 204, 0) font-weight: bold>Price: $\n"; echo " $price_currency</span></small></td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td colspan=1 rowspan=3><small><span\n"; echo " style=font-family: Helvetica,Arial,sans-serif><img src=$imgSrc></span></small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 147px><small>Condition:\n"; echo " $condition</small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 109px><small></small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 141px><small></small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 147px><small></small></td>\n"; echo " </tr>\n"; echo " <tr width=147\n"; echo " style=font-family: Helvetica,Arial,sans-serif>\n"; echo " <small></small><td\n"; echo " style=background-color: black width: 147px colspan=4 \n"; echo " rowspan=1><span style=color: rgb(255, 204, 0)><a href=\"http://heavyequipmentwantedads.com/icardemo/inventory/getitems.php?&$vehicleID\" title=\"Full Details (View)\" target=\"_new\">Full Details (View)</a></span></td>\n"; echo " <small></small></tr>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 147px><small>Transmission\n"; echo " : $transmission</small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 109px><small>Doors:\n"; echo " $doors</small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 141px><small>FuelType: $fueltype</small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 147px><small>KM:\n"; echo " $kilometers</small></td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td style=background-color: rgb(204, 204, 204)><small></small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 147px><small>Cylinders:\n"; echo " $cylinders</small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 109px><small></small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 141px><small>Features: $featurestring</small></td>\n"; echo " <td\n"; echo " style=font-family: Helvetica,Arial,sans-serif width: 147px><small></small></td>\n"; echo " </tr>\n"; echo " </tbody>\n"; echo " </table>\n"; Partial listing of items: Code: [Select] <?php $xmldata ='<dealerAccount> <accountNum>xxxxxx</accountNum> <dealerPwd>xxxxxxxxx</dealerPwd> <data>item</data> <vehicleID>'.$vehicleID.'</vehicleID> </dealerAccount>'; $URL = "http://www.wheelsonline.ca/api/"; $ch = curl_init($URL); //curl_setopt($ch, CURLOPT_MUTE, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); curl_setopt($ch, CURLOPT_POSTFIELDS, "$xmldata"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); $doc=new DOMDocument(); $doc->loadXML($output); $items=$doc->getElementsByTagName("item"); $results = print_r($xmlarray, true); echo $results; ?> php can detect "mac address", "ip address", "browser agent", "cookie" and "hostname". What else php can detect? I have a form with a table that contains ONLY dropdown menus for users to select quantities from 25 dinner items. It contains some Javascript, but nothing fancy. In an effort to establish my database and TEST to see how some PHP functions might respond so I could improve my form, I created a mini version of the db in MySQL. But when I click the submit button, the page blinks, the address bar fills with field names, but there is no connect. No error messages. No data transfer. NO NOTHING! I searched the web and copied a form and plugged it in (an html form, a php insert file, and a MySQL database) and it worked fine. I peared down my page to mirror it, and still, no success. What little detail am I missing?? If I have 25 fields but create a db for the first 6, should it function? If I reduce it and try to re-use the same db, am I persuing a problem? I've tried error trapping and changing the form inputs, but it just still doesn't connect. Please help! Hello, I have a database with the following tables: students groups exams examDay relation master detail ======= ===== ===== ======= ====== ====== ===== idStudent idGroup idExam idExDay idRelation idMaster idDetail idGroup groupName examName exDate idGroup idGroup idMaster studName idExDay idRelation idExam idExam idStudent coursesAtt idExDay I am trying to make a report from the Master and Detail tables that will have the table header like this: Group | Examination Date | Student Name | Exam1 | Exam2| .... | Exam n in which Exam1, Exam2,... are the exams names and they had to take the values from coursesAtt column. Is this possible? I could make a view (doing joins and group by) by the results will be displayed on row. That's why I ask for your help. Thanks Hi all expert. I am a newbie in this PHP programming. I need your help or advise on the PHP. And question is, I have a list of data and the details are as below:
ID BILLNO DATE AMOUNT ITEM DESCRIPTION QTY UPRICE 1 IV001 01/01/2015 100.00 A1 Balloon 1 30.00 2 IV001 01/01/2015 100.00 A2 Bag 2 20.00 3 IV001 01/01/2015 100.00 A3 Pen 3 10.00 4 IV002 02/01/2015 20.00 A3 Pen 2 10.00 5 IV003 02/01/2015 50.00 A1 Balloon 1 30.00 6 IV003 02/01/2015 50.00 A2 Bag 1 20.00 How can I make the output in xml by using PHP to output as below: <RECORD> <HEADER BILLNO="IV001" DATE="01/01/2015" AMOUNT="100.00> <DETAIL ITEM="A1" DESCRIPTION="Balloon" QTY="1" UPRICE="30.00"> </DETAIL> <DETAIL ITEM="A2" DESCRIPTION="Bag" QTY="2" UPRICE="20.00"> </DETAIL> <DETAIL ITEM="A3" DESCRIPTION="Pen" QTY="3" UPRICE="10.00"> </DETAIL> </HEADER> <HEADER BILLNO="IV002" DATE="02/01/2015" AMOUNT="20.00> <DETAIL ITEM="A3" DESCRIPTION="Balloon" QTY="2" UPRICE="10.00"> </DETAIL> </HEADER> </RECORD> Your feedback is highly appreciated. Thank you. |