graham23s Posted February 13, 2008 Share Posted February 13, 2008 Hi Guys, i have this block of code i use to display products in an online shop: // display box for products // $display_box = "<form action=\"shoppingcart.php\" method=\"get\">\n"; $display_box = "<div id=\"right\">\n"; $display_box .= "<div class=\"boxtop\">\n"; $display_box .= "</div>"; $display_box .= "<div class=\"box\">"; $display_box .= "<img src=\"images/image.gif\" alt=\"Product Image\" title=\"Product Image\" class=\"image\" />\n"; $display_box .= "<b>$product_name</b>"; $display_box .= "<br />"; $display_box .= "<br />"; $display_box .= "$product_description"; $display_box .= "<br />"; $display_box .= "<hr />"; $display_box .= "<input type=\"hidden\" name=\"productid\" value=\"$productid\" />"; $display_box .= "<input type=\"submit\" name=\"submit\" value=\"Add To Cart\" />"; $display_box .= "<hr />"; $display_box .= "<span class=\"price\">$2.99</span>"; $display_box .= "<br />"; $display_box .= "<hr />"; $display_box .= "<b>Quantity:</b>-"; $display_box .= "<select name=\"quantity\">"; $display_box .= "<option value=\"1\">1</option>"; $display_box .= "<option value=\"2\">2</option>"; $display_box .= "<option value=\"3\">3</option>"; $display_box .= "</select>"; $display_box .= "</div>\n"; $display_box .= "</div>\n"; $display_box .= "</div>\n"; $display_box .= "</form>\n"; the way it is above the button does forward you to the shoppingcart.php, but when i move it down a few lines it work, but then throws my css out of whack, is there anywhere specific i should put it? heres the full page: <?php session_start(); include("inc/dbconnection.php"); include("inc/online.php"); include("inc/header.php"); include("inc/navigation.php"); ?> <?php // get the id // $categoryid = $_GET['id']; // query the db // $queryproduct = "SELECT * FROM `fcp_categories` WHERE `id`='$categoryid'"; $resultproduct = mysql_query($queryproduct) or die (mysql_error()); $row = mysql_fetch_array($resultproduct) or die (mysql_error()); // vars // $catname = $row['categoryname']; // set the rane // $quantity = range(1,99); // get and display all the products associated with this cat // $queryproducts = "SELECT * FROM `fcp_products` WHERE `category_id`='$categoryid'"; $resultsproducts = mysql_query($queryproducts) or die (mysql_error()); // number of products // $numproducts = mysql_num_rows($resultsproducts); // standard header // print("<div class=\"subheader\"><div id=\"title\">Category > <span class=\"blue\">$catname</span></div>We have <b>$numproducts</b> products in this category for you to browse.</div>"); //--------------------------------------------// // need modulous to display them properly // $i = 0; // begin the table // print("<table class=\"products_table\" align=\"center\" width=\"100%\" border=\"0\" cellpadding=\"10\" cellspacing=\"0\">"); // start the while loop // while ($rows = mysql_fetch_array($resultsproducts)) { $productid = $rows['id']; $product_name = $rows['product_name']; $product_description = $rows['product_description']; // display box for products // $display_box = "<form action=\"shoppingcart.php\" method=\"get\">\n"; $display_box = "<div id=\"right\">\n"; $display_box .= "<div class=\"boxtop\">\n"; $display_box .= "</div>"; $display_box .= "<div class=\"box\">"; $display_box .= "<img src=\"images/image.gif\" alt=\"Product Image\" title=\"Product Image\" class=\"image\" />\n"; $display_box .= "<b>$product_name</b>"; $display_box .= "<br />"; $display_box .= "<br />"; $display_box .= "$product_description"; $display_box .= "<br />"; $display_box .= "<hr />"; $display_box .= "<input type=\"hidden\" name=\"productid\" value=\"$productid\" />"; $display_box .= "<input type=\"submit\" name=\"submit\" value=\"Add To Cart\" />"; $display_box .= "<hr />"; $display_box .= "<span class=\"price\">$2.99</span>"; $display_box .= "<br />"; $display_box .= "<hr />"; $display_box .= "<b>Quantity:</b>-"; $display_box .= "<select name=\"quantity\">"; $display_box .= "<option value=\"1\">1</option>"; $display_box .= "<option value=\"2\">2</option>"; $display_box .= "<option value=\"3\">3</option>"; $display_box .= "</select>"; $display_box .= "</div>\n"; $display_box .= "</div>\n"; $display_box .= "</div>\n"; $display_box .= "</form>\n"; if ($i==0) { print('<tr><td align="center">'.$display_box.'</td>'); } elseif ($i == 2) { print('<td align="center">'.$display_box.'</td></tr>'); } else { print('<td align="center">'.$display_box.'</td>'); } $i++; $i=$i % 2; // mod 2 gives you the remainder // } // end the while loop // // end the products tabel // print("</tr>"); print("</table>"); ?> <?php // include the footer // include("inc/footer.php"); ?> thanks guys Graham Link to comment https://forums.phpfreaks.com/topic/90940-submit-not-working/ Share on other sites More sharing options...
Skittalz Posted February 13, 2008 Share Posted February 13, 2008 $display_box = "<form action=\"shoppingcart.php\" method=\"get\">\n"; $display_box = "<div id=\"right\">\n"; Doesn't the second line over write the first? I think you need $display_box = "<form action=\"shoppingcart.php\" method=\"get\">\n"; $display_box .= "<div id=\"right\">\n"; Link to comment https://forums.phpfreaks.com/topic/90940-submit-not-working/#findComment-466076 Share on other sites More sharing options...
haku Posted February 13, 2008 Share Posted February 13, 2008 What exactly is the problem? It sounds like its working now, why do you want to change it? Link to comment https://forums.phpfreaks.com/topic/90940-submit-not-working/#findComment-466080 Share on other sites More sharing options...
graham23s Posted February 13, 2008 Author Share Posted February 13, 2008 it is indeed working now thanks Skittalz that was the problem. Graham Link to comment https://forums.phpfreaks.com/topic/90940-submit-not-working/#findComment-466088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.