dpny
04-28-2004, 07:59 PM
I have the below code, what I am trying to do is change the way it outputs the information... I have a different table on how I want the output to be displayed.. how would I do that? I tried playing around it but keep getting error.!
Here is the code:
if ($_GET ["product"])
{
$query = "SELECT * FROM products WHERE product_id = \"".$_GET ["product"]."\" AND active=\"yes\"";
$result = mysql_query ($query);
if (!mysql_num_rows ($result))
{
$page_data = "<p> </p><p align=\"center\" class=\"error\">This product doesn't exist.</p><p> </p>";
}
else
{
while ($data = mysql_fetch_array ($result))
{
if ($_GET ["zoom"])
{
// show zoom photo only
$page_data = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n
<tr valign=\"top\"><td align=\"center\">[ <a href=\"".URL_ROOT."?product=".$data ["product_id"]."&category=".$data ["cat_id"]."&parent=".$_GET ["parent"]."\" class=\"return_link\">Back to Main Description</a> ]<br>\n
<a href=\"".URL_ROOT."?product=".$data ["product_id"]."&category=".$data ["cat_id"]."&parent=".$_GET ["parent"]."\"><img src=\"".PRODUCT_IMAGE_XL.$data ["image"]."\" border=\"1\"></a><br>\n
[ <a href=\"".URL_ROOT."?product=".$data ["product_id"]."&category=".$data ["cat_id"]."&parent=".$_GET ["parent"]."\" class=\"return_link\">Back to Main Description</a> ]<br></td>\n";
}
else
{
if (file_exists (LARGE_IMAGE.$data ["image"]))
{
$show_product_image = "<img src=\"".PRODUCT_IMAGE_LARGE.$data ["image"]."\" width=300 border=\"1\"><br><br>\n";
if (file_exists (XL_IMAGE.$data ["image"]))
{
$show_product_image .= "<a href=\"".URL_ROOT."?product=".$data ["product_id"]."&zoom=yes&category=".$data ["cat_id"]."&parent=".$_GET ["parent"]."\" class=\"mainsm\"><img src=\"".IMAGE_URL."zoom.gif\" border=\"0\"> Zoom</a>";
}
}
// show details
$page_data = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n
<tr valign=\"top\"><td>
<table width=\"255\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"left\">\n
<tr><td align=\"center\">$show_product_image</td></tr></table>
<p align=\"center\" class=\"product_title\">".$data ["title"]."</p>
<p class=\"main\">".$data ["long_description"]."</td>\n";
}
// deal with shipping
if (SHIPPING_TYPE == "item")
{
$shipping_vars = "<input type=\"hidden\" name=\"shipping\" value=\"".$data ["shipping"]."\">\n
<input type=\"hidden\" name=\"shipping2\" value=\"".$data ["shipping_extra"]."\">";
}
// deal with product options
if ($data ["option_1"])
{
$option_1_dropdown = Build_Product_Options (1, $data ["option_1"]);
}
if ($data ["option_2"])
{
$option_2_dropdown = Build_Product_Options (2, $data ["option_2"]);
}
// show price info on right
$page_data .= "<td width=\"150\"><table width=\"150\" border=\"0\" bordercolor=\"#000000\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"".BACKGROUND_NAV."\">\n
<tr height=\"28\"><td align=\"center\" class=\"nav_header\">".PRICING_HEADER."</td>\n
</tr><tr>\n
<form target=\"paypal\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">
<td class=\"nav_main\"><br>
Name:<br>".$data ["title"]."<br><br>
SKU: ".$data ["sku"]."<br><br>
Price: ".CURRENCY_SYMBOL." ".number_format ($data ["price"], 2)."<br><br>
In Stock: ".$data ["in_stock"]."<br><br>";
$page_data .= $option_1_dropdown;
$page_data .= $option_2_dropdown;
$page_data .= "<p align=\"center\">
<input type=\"hidden\" name=\"cmd\" value=\"_cart\">
<input type=\"hidden\" name=\"business\" value=\"".PAYPAL_ACCOUNT."\">
<input type=\"hidden\" name=\"item_name\" value=\"".$data ["invoice_description"]."\">
<input type=\"hidden\" name=\"item_number\" value=\"".$data ["product_id"]."\">
<input type=\"hidden\" name=\"amount\" value=\"".number_format ($data ["price"], 2)."\">
<input type=\"hidden\" name=\"currency_code\" value=\"".CURRENCY."\">";
$page_data .= $shipping_vars;
$page_data .= "<input type=\"hidden\" name=\"add\" value=\"1\">
<input type=\"hidden\" name=\"return\" value=\"".URL_ROOT."?page=order_finish\">";
if ($data ["in_stock"] == "Yes")
{
$page_data .= "<input type=\"image\" src=\"".IMAGE_URL.ADD_TO_CART."\" border=\"0\" name=\"submit\" title=\"Add To Cart\">";
}
else
{
$page_data .= "<img src=\"".IMAGE_URL.OUT_OF_STOCK."\" border=\"0\">\n";
}
$page_data .= "<br><br>\n</td>\n</form>\n</tr>\n</table>\n</td></tr></table>";
}
}
$next_page = "display";
}
basically what I want is organize this code to make it more compact as in just displaying all the information without the table like:
$page_data="
$show_product_image <br>
Title: ".$data ["title"]." <br>
SKU: ".$data ["sku"]." <br>
Price: ".CURRENCY_SYMBOL." ".number_format ($data ["price"], 2)."<br>
In Stock: ".$data ["in_stock"]."
<br><br>
".$data ["long_description"]." <br><br> \n";
$page_data .= $option_1_dropdown;
$page_data .= $option_2_dropdown;
right after this, rest of the paypal button code could go...
Here is the code:
if ($_GET ["product"])
{
$query = "SELECT * FROM products WHERE product_id = \"".$_GET ["product"]."\" AND active=\"yes\"";
$result = mysql_query ($query);
if (!mysql_num_rows ($result))
{
$page_data = "<p> </p><p align=\"center\" class=\"error\">This product doesn't exist.</p><p> </p>";
}
else
{
while ($data = mysql_fetch_array ($result))
{
if ($_GET ["zoom"])
{
// show zoom photo only
$page_data = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n
<tr valign=\"top\"><td align=\"center\">[ <a href=\"".URL_ROOT."?product=".$data ["product_id"]."&category=".$data ["cat_id"]."&parent=".$_GET ["parent"]."\" class=\"return_link\">Back to Main Description</a> ]<br>\n
<a href=\"".URL_ROOT."?product=".$data ["product_id"]."&category=".$data ["cat_id"]."&parent=".$_GET ["parent"]."\"><img src=\"".PRODUCT_IMAGE_XL.$data ["image"]."\" border=\"1\"></a><br>\n
[ <a href=\"".URL_ROOT."?product=".$data ["product_id"]."&category=".$data ["cat_id"]."&parent=".$_GET ["parent"]."\" class=\"return_link\">Back to Main Description</a> ]<br></td>\n";
}
else
{
if (file_exists (LARGE_IMAGE.$data ["image"]))
{
$show_product_image = "<img src=\"".PRODUCT_IMAGE_LARGE.$data ["image"]."\" width=300 border=\"1\"><br><br>\n";
if (file_exists (XL_IMAGE.$data ["image"]))
{
$show_product_image .= "<a href=\"".URL_ROOT."?product=".$data ["product_id"]."&zoom=yes&category=".$data ["cat_id"]."&parent=".$_GET ["parent"]."\" class=\"mainsm\"><img src=\"".IMAGE_URL."zoom.gif\" border=\"0\"> Zoom</a>";
}
}
// show details
$page_data = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n
<tr valign=\"top\"><td>
<table width=\"255\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"left\">\n
<tr><td align=\"center\">$show_product_image</td></tr></table>
<p align=\"center\" class=\"product_title\">".$data ["title"]."</p>
<p class=\"main\">".$data ["long_description"]."</td>\n";
}
// deal with shipping
if (SHIPPING_TYPE == "item")
{
$shipping_vars = "<input type=\"hidden\" name=\"shipping\" value=\"".$data ["shipping"]."\">\n
<input type=\"hidden\" name=\"shipping2\" value=\"".$data ["shipping_extra"]."\">";
}
// deal with product options
if ($data ["option_1"])
{
$option_1_dropdown = Build_Product_Options (1, $data ["option_1"]);
}
if ($data ["option_2"])
{
$option_2_dropdown = Build_Product_Options (2, $data ["option_2"]);
}
// show price info on right
$page_data .= "<td width=\"150\"><table width=\"150\" border=\"0\" bordercolor=\"#000000\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"".BACKGROUND_NAV."\">\n
<tr height=\"28\"><td align=\"center\" class=\"nav_header\">".PRICING_HEADER."</td>\n
</tr><tr>\n
<form target=\"paypal\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">
<td class=\"nav_main\"><br>
Name:<br>".$data ["title"]."<br><br>
SKU: ".$data ["sku"]."<br><br>
Price: ".CURRENCY_SYMBOL." ".number_format ($data ["price"], 2)."<br><br>
In Stock: ".$data ["in_stock"]."<br><br>";
$page_data .= $option_1_dropdown;
$page_data .= $option_2_dropdown;
$page_data .= "<p align=\"center\">
<input type=\"hidden\" name=\"cmd\" value=\"_cart\">
<input type=\"hidden\" name=\"business\" value=\"".PAYPAL_ACCOUNT."\">
<input type=\"hidden\" name=\"item_name\" value=\"".$data ["invoice_description"]."\">
<input type=\"hidden\" name=\"item_number\" value=\"".$data ["product_id"]."\">
<input type=\"hidden\" name=\"amount\" value=\"".number_format ($data ["price"], 2)."\">
<input type=\"hidden\" name=\"currency_code\" value=\"".CURRENCY."\">";
$page_data .= $shipping_vars;
$page_data .= "<input type=\"hidden\" name=\"add\" value=\"1\">
<input type=\"hidden\" name=\"return\" value=\"".URL_ROOT."?page=order_finish\">";
if ($data ["in_stock"] == "Yes")
{
$page_data .= "<input type=\"image\" src=\"".IMAGE_URL.ADD_TO_CART."\" border=\"0\" name=\"submit\" title=\"Add To Cart\">";
}
else
{
$page_data .= "<img src=\"".IMAGE_URL.OUT_OF_STOCK."\" border=\"0\">\n";
}
$page_data .= "<br><br>\n</td>\n</form>\n</tr>\n</table>\n</td></tr></table>";
}
}
$next_page = "display";
}
basically what I want is organize this code to make it more compact as in just displaying all the information without the table like:
$page_data="
$show_product_image <br>
Title: ".$data ["title"]." <br>
SKU: ".$data ["sku"]." <br>
Price: ".CURRENCY_SYMBOL." ".number_format ($data ["price"], 2)."<br>
In Stock: ".$data ["in_stock"]."
<br><br>
".$data ["long_description"]." <br><br> \n";
$page_data .= $option_1_dropdown;
$page_data .= $option_2_dropdown;
right after this, rest of the paypal button code could go...
