laurelsstitchery Posted December 16, 2005 Share Posted December 16, 2005 I've downloaded the categories_anywhere contribution and set it up with my database information. I can't get it to display anything though. Here's a screen shot of what it does display: Screen Shot. I don't know what code I would need to copy and paste here in order for somebody to check it to see if it's correct or not. Any ideas? Quote Laurel Link to comment Share on other sites More sharing options...
laurelsstitchery Posted December 16, 2005 Author Share Posted December 16, 2005 Here's my complete code with the database info blanked out. Let me know what I'm missing here. I've followed the instructions to the letter. <?php //Here are the variables you must set. $db_server = "***"; //database server $db_user = "***"; //database user $db_pass = "***"; //database password $db_name = "***"; //database name $domain_name = "www.rainbowstitchery.com"; //don't slashes or http: $catalog_folder_name = "catalog"; //no slashes $site_title = "Laurel's Stitchery"; //site name $category_display = "277"; //category id $image_width = "100"; //how wide your images should be $image_height = "100"; // how high your images should be $num_products = "33"; //max number of products per page $prod_col = "3"; //number of columns per page $table_width = "95"; // table width in percent don't use % $table_align = "center"; //table alignment $table_cspace = "3"; //table cellspacing $table_cpadd = "3"; //table cellpadding $product_price = "1"; //show prices? (1 is on, 0 is off) $product_image = "1"; //show images? (1 is on, 0 is off) $product_info_link = "1"; //show link to product_info.php? (1 is on, 0 is off) $product_buy_link = "1"; //show link to shopping cart? (1 is on, 0 is off) //Now upload to your website and your should be done!//Email me at [email protected] if you have any problems. ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html dir="LTR" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title><?php echo $site_title; ?></title> <style type="text/css"> <!-- body {background: #FFFFFF;color: #000000;margin: 0px 0px 0px 0px;padding: 0px;font-family: verdana, geneva, arial, helvetica,sans-serif;font-size: 10pt;} a:link {text-decoration: none;background: transparent;color: #000000;font-weight: bold;font-size: 10pt;} a:visited {text-decoration: none;background: transparent;color: #000000;font-weight: bold;font-size: 10pt;} a:hover {text-decoration: underline;background: transparent;color: #000000;font-weight: bold;font-size: 10pt;} a:active {text-decoration: underline;background: transparent;color: #000000;font-weight: bold;font-size: 10pt;} .content {border: 1px solid #AEAEAE;font-size: 10pt;} td {color: #000000;font-weight: bold;font-size: 10pt;} select {background: #666666; color: white; border-bottom: 0px solid; border-left: 0px solid;border-right: 0px solid;border-top: 0px solid;font:12px arial, helvetica,sans-serif;} --> </style> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <?php echo "<table width=\"$table_width%\" align=\"$table_align\" cellspacing=\"$table_cspace\" cellpadding=\"$table_cpadd\"><tr>"; $tdwidth = round($table_width/$prod_col) - 1; // create connection $connection = mysql_connect("$db_server","$db_user","$db_pass") or die("Couldn't make connection."); // select database $db = mysql_select_db("$db_name", $connection) or die("Couldn't select database."); if (!$pl) {$pl = "0";} if (!$ph) {$ph = $num_products;} // create SQL statement $sqlcount = "SELECT * FROM `products` ORDER BY 'products_model'"; $sql = "SELECT * FROM `products` p, `products_to_categories` p2c where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = '" . $category_display . "' ORDER BY RAND() DESC LIMIT $pl, $num_products"; // execute SQL query and get result $sql_result = mysql_query($sql,$connection) or die("Couldn't execute query."); $sqlcount_result = mysql_query($sqlcount,$connection) or die("Couldn't execute query."); $num = mysql_numrows($sqlcount_result); mysql_free_result($sqlcount_result); //echo $num; $prod_result = ($prod_col + 1)/2; //echo $prod_result; $i = 1; // format results by row while ($row = mysql_fetch_array($sql_result)) { $id = $row["products_id"]; $model = $row["products_model"]; $image = $row["products_image"]; $price = $row["products_price"]; $sql2 = "SELECT `products_name` FROM `products_description` WHERE products_id = '$id' LIMIT 1"; $sql2_result = mysql_query($sql2,$connection) or die("Couldn't execute query."); $row2 = mysql_fetch_array($sql2_result); $name = $row2["0"]; $products_image_replace = str_replace("./", "/", $image); $products_price_replace = str_replace(".0000", "", $price); $idiv = $i/2; if ($idiv == $prod_result) { echo "</tr><tr>"; $i = 1; } else { } echo "<td align=\"center\" width=\"$tdwidth%\" class=\"content\">"; if ($product_info_link == "1") { if ($product_image == "1") { echo "<a href=\"http://$domain_name/$catalog_folder_name/product_info.php/products_id/$id\" target=\"_blank\"><img src=\"http://$domain_name/$catalog_folder_name/images$products_image_replace\" width=\"$image_width\" height=\"$image_height\" border=\"0\"><br>$name</a><br>"; } else { echo "<a href=\"http://$domain_name/$catalog_folder_name/product_info.php/products_id/$id\" target=\"_blank\">$name</a><br>"; } } else { if ($product_image == "1") { echo "<img src=\"http://$domain_name/$catalog_folder_name/images$products_image_replace\" width=\"$image_width\" height=\"$image_height\" border=\"0\"><br>$name<br>"; } else { echo "$name<br>"; } } if ($product_price == "1") { echo "\$$products_price_replace<br>"; } else { } if ($product_buy_link == "1") { echo "<a href=\"http://$domain_name/$catalog_folder_name/default.php/action/buy_now/products_id/$id\">Buy Now</a></td>"; } else { } $i++; } // free resources and close connection mysql_free_result($sql_result); mysql_close($connection); ?> </table> <?php echo "<table width=\"$table_width%\" align=\"$table_align\" cellspacing=\"$table_cspace\" cellpadding=\"$table_cpadd\"><tr><td align=\"center\"><form action=\"$PHP_SELF\" method=\"get\">"; if (!$pl || ($pl == 0)) { } else { $prepl = $pl - $num_products; echo "[<a href=\"$PHP_SELF?pl=$prepl\">Previous</a>] "; } echo "<select name=\"pl\" onChange=\"this.form.submit();\" size=\"1\"><option value=\"\" SELECTED>Page Jump</option>"; $page_count = round($num / ($num_products)) - 1; $j = 0; while ($j <= $page_count) { $page = $j+1; $newpl1 = $num_products*$j; if ($j == 0) { $newpl = "0"; } else { $newpl = ($j*$num_products)+1; } echo "<option value=\"$newpl\">$page</option>"; $j++; } $nextpl = $num_products + $pl; echo "</select> [<a href=\"$PHP_SELF?pl=$nextpl\">Next</a>]</form></td></tr></table>"; ?> </body> </html> Quote Laurel Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.