产品从我的MySQL数据库通过phpmyadmin似乎没有显示在我的网站上。我用的是Netbeans &Wamp
代码:处理我的图像
<div class="catalogue_wrapper">
<div class="catalogue_wrapper_left">
<?php
$image = !empty($row['image']) ?
$objCatalogue->_path.$row['image'] :
$objCatalogue->_path.'unavailable.png';
$width = Helper::getImgSize($image, 0);
$width = $width > 120 ? 120 : $width;
?>
<a href="?page=catalogue-item&category=<?php echo $category['id']; ?>&id=<?php echo $row['id']; ?>"><img src="<?php echo $image; ?>" alt="<?php echo Helper::encodeHtml($row['name'], 1); ?>" width="<?php echo $width; ?>" /></a>
</div>
代码:Should display my products
<div class="catalogue_wrapper_right">
<h4><a href="?page=catalogue-item&category=<?php echo $category['id']; ?>&id=<?php echo $row['id']; ?>"><?php echo Helper::encodeHtml($row['name'], 1); ?></a></h4>
<h4>Price: <?php echo Catalogue::$_currency; echo number_format($row['price'], 2); ?></h4>
<p><?php echo Helper::shortenString(Helper::encodeHtml($row['description'])); ?></p>
<p><?php echo Basket::activeButton($row['id']); ?></p>
</div>
</div>
每次我点击链接,它都会显示我的错误信息。
任何帮助将不胜感激得到这些产品显示在我的web应用程序。
是两个表的SQL转储
-- phpMyAdmin SQL Dump
-- version 4.1.8
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 23, 2014 at 03:06 AM
-- Server version: 5.6.12-log
-- PHP Version: 5.4.16
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `tllecommerce`
--
-- --------------------------------------------------------
--
-- Table structure for table `categories`
--
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(150) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
--
-- Dumping data for table `categories`
--
INSERT INTO `categories` (`id`, `name`) VALUES
(1, 'Liquorice'),
(2, 'Fudge'),
(3, 'Nougat'),
(4, 'Toffee'),
(5, 'Combination'),
(6, 'Allsorts'),
(7, 'Liquorice Straps');
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE IF NOT EXISTS `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`description` text NOT NULL,
`price` decimal(8,2) NOT NULL,
`date` datetime NOT NULL,
`category` int(11) NOT NULL,
`image` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `category` (`category`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=23 ;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`id`, `name`, `description`, `price`, `date`, `category`, `image`) VALUES
(1, 'Herbal Liquorice Straps', 'Cut your own straps!rnrnRolled liquorice sheets flavoured with the popular Chinese herbal extract Glycyrrhiza Glabra. Has the same medicinal and nutritional properties as Herbal Liquorice Bites but a slightly more intense flavour.', '8.00', '2014-03-17 07:59:43', 7, 'Blackstrapszoom.jpg'),
(2, 'Raspberry Sheets', 'Cut your own straps!rnrnThis is a tasty extrusion of the raspberry log, but with a more intense flavour.', '8.00', '2014-03-17 08:02:17', 7, 'raspberrystrapszoom.jpg'),
(3, 'Chocolate Liquorice Logs', 'Another “best seller”. Similar to the Rasso Choco except that the chocolate centre is wrapped in New Generation''s soft-chew herbal liquorice. rnrnIf you like liquorice, you will enjoy these. Like the rasso-choco keep it sealed in the fridge. Tip: Cut into short lengths and enjoy with vanilla ice-cream.', '8.00', '2014-03-17 08:05:14', 1, 'chocliqlogZoom.jpg'),
(4, 'Irish Moss Liquorice', 'Not truly a liquorice but a fresh soft jube impregnated with aniseed and covered with colourful hundreds and thousands. Often fought over in a pottle of Allsorts. This item has a long history in confectionery.', '8.00', '2014-03-17 08:08:12', 1, 'irishmosszoom.jpg'),
(5, 'Peaches and Cream Liquorice', 'Slightly piquant, but very pleasant on the palate, this tasty little number is sure to please. rnrnFlavoured with peach essence and mixed with artificial cream to keep unsaturated fats low, it tastes, as you might expect, of peaches and cream.', '8.00', '2014-03-17 08:09:00', 1, 'peachesNchreamzoom.jpg'),
(6, 'Liquorice Herbal Logs', 'Liquorice logs flavoured this time with something rather different: a popular Chinese herbal extract - Glycyrrhiza Glabra. rnrnGG runs a close-second to the well-known extract, Ginseng, used in Chinese herbal medicine.', '8.00', '2014-03-17 08:11:14', 1, 'softchewHerbLiqZoom.jpg'),
(7, 'Raspberry Chocolate Liquorice', 'Our ever-popular raspberry-flavoured roll wrapped around crunchy compound chocolate.rnrnThe cooler it is kept, the crunchier the chocolate becomes. rnrnIf you freeze it, just suck it until it becomes soft enough to eat. A tasty combination of flavours and textures. Keep the pottle sealed. A favourite with the younger set.', '8.00', '2014-03-17 08:14:00', 1, 'rassochocozoom.jpg'),
(8, 'Assorted Liquorice', 'Individually flavoured, lime, banana, plum and orange cubes in the traditional form: two liquorice and three paste (fruit) layers. Savour each flavour one cube at a time – and return for rna different flavour later.', '8.00', '2014-03-17 08:16:02', 6, 'allsortzoom.jpg'),
(9, 'Mini Bag Liquorice Allsorts', 'These versatile little bags are great for fund-raising (schools, clubs), for business promotions and/or give-aways to good customers or to encourage repeat business.rnrnFor schools & clubs the minimum order is 500 bags; for small businesses 100 bags.rnrnThe goods have a shelf life of 12 months.', '4.00', '2014-03-17 08:19:00', 6, 'minbag2zoom.jpg'),
(10, 'The Assorted Mini Pottle', 'Fill it with just one liquorice variety or any assortment from within the product range. rnrnMini pottles are popular in the business community as small give-away gifts of appreciation. A great value-for-money option.', '8.00', '2014-03-17 08:21:00', 6, 'minipottlezoom.gif'),
(11, 'Fruit Mix', 'Mixed fruity liquorice: apricot, blueberry, pineapple, kiwifruit and coconut – a combination you''re unlikely to find anywhere else. rnrnEach individual allsort contains natural fruit essence and an extra burst of flavour from dried fruit mixed into the paste. A delight for the taste buds.', '8.00', '2014-03-17 08:24:00', 6, 'MixedFruitzoom.jpg'),
(12, 'Chocolate Fudge', 'A chocolate flavoured fudge, light in texture and flavour. rnrnAnother high-quality NZ product using the best milk products and flavourings.', '8.00', '2014-03-17 08:26:00', 2, 'ChocZoom.jpg'),
(13, 'Liquorice Fudge', 'If you love liquorice this will be for you. Fudge that manages to combine the taste of liquorice with the texture and taste of fudge.', '8.00', '2014-03-17 08:27:00', 2, 'LiquoriceFudgeZoom.jpg'),
(14, 'Russian Fudge', 'A sweet and full-bodied fudge which is neither heavy nor tacky. More-ish. Uses the best available milk products and ingredients. Another long-lasting favourite.', '8.00', '2014-03-17 08:28:00', 2, 'RussianZoom.jpg'),
(15, 'Irish Creme Fudge', 'Lovers of Irish Creme will quickly identify its flavour in this finely textured fudge. rnrnLight, tasty, satisfying and not cloying. Long-lasting and made with the best ingredients.rn', '8.00', '2014-03-17 08:30:00', 2, 'IrishCremeZoom.jpg'),
(16, 'Ginger Liquorice Nougat', 'Added to the NGL mix for lovers of ginger.rnCrystallised ginger and liquorice are melted into nougat fresh from the ovens to give a tasty and beautifully balanced treat.rnrnThe ginger flavour slowly builds on the palate after about 20 seconds but is never too strong. One or two pieces are all you need.rnrnA great gift for more senior members of the family.', '8.00', '2014-03-17 08:31:00', 3, 'GingerLiqzoom.jpg'),
(17, 'Raspberry Nougat', 'One of our best sellers - pushing the factory into overtime to keep up with demand.rnrnRaspberry logs are melted into the nougat as soon as it comes from the ovens. If you enjoy a raspberry flavour you''ll certainly like this combination.rnrnThe product has the same texture as Liquorice Nougat - firm but not chewy.', '8.00', '2014-03-17 08:33:00', 3, 'RaspNougatzoom.jpg'),
(18, 'Pineapple Nougat', 'Promises to be popular! Freshly dried pineapple and pineapple essence give a strong pineapple flavour beautifully balanced by the nougat. rnrnAnother NZ-made product using the best of ingredients.', '8.00', '2014-03-17 08:34:00', 3, 'PineappleNougatZOOM.jpg'),
(19, 'Liquorice Nougat', 'Eating Ecstasy!rnrnLike Nougat? Then you''re bound to enjoy this - natural liquorice logs embedded in fresh nougat. rnrnThe nougat has the same consistency as the liquorice (firm but not chewy) and the two flavours are a unique blend.', '8.00', '2014-03-17 08:36:00', 3, 'LiqNougatzoom.jpg'),
(20, 'Toffee', 'Something different...rnrnThis is a rather soft chewing lolly with the liquorice and aniseed combining to produce subtle flavours. rnrnIndividually wrapped.', '8.00', '2014-03-17 08:38:00', 4, 'toffeeZoom.jpg'),
(21, 'Liquorice Combo', '700 grams of liquorice combination', '15.00', '2014-03-17 08:40:00', 5, NULL),
(22, 'Nougat Combo', '700 grams of nougat combination', '15.00', '2014-03-17 08:41:00', 5, NULL);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `products`
--
ALTER TABLE `products`
ADD CONSTRAINT `products_ibfk_1` FOREIGN KEY (`category`) REFERENCES `categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
在phpMyAdmin中运行此查询并检查是否得到任何结果,如果没有,则意味着数据库中不存在属于您试图获取的类别的产品
$table1 = "products" ;
$table2 = "categories" ;
SELECT * FROM $table1 LEFT JOIN $table2 ON $table2.`category` = $table1.`id` WHERE $table1.`category` = $cat ORDER BY $table1.`date` DESC