Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试在我的netbeans php项目中显示我的产品_Php_Mysql_Netbeans - Fatal编程技术网

尝试在我的netbeans php项目中显示我的产品

尝试在我的netbeans php项目中显示我的产品,php,mysql,netbeans,Php,Mysql,Netbeans,通过phpmyadmin从MySQL数据库中获得的产品似乎没有显示在我的网站上。我正在使用Netbeans和Wamp 代码:处理我的图像 <div class="catalogue_wrapper"> <div class="catalogue_wrapper_left"> <?php $image = !empty($row['image']) ? $objCatalogue->_p

通过phpmyadmin从MySQL数据库中获得的产品似乎没有显示在我的网站上。我正在使用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&amp;category=<?php echo $category['id']; ?>&amp;id=<?php echo $row['id']; ?>"><img src="<?php echo $image; ?>" alt="<?php echo Helper::encodeHtml($row['name'], 1); ?>" width="<?php echo $width; ?>" /></a>
    </div>

在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

错误消息是什么?查询在哪里?错误消息:
}否则{?>此类别中没有产品。

您需要检查您的查询。查询在我的目录类中:公共函数getProducts($cat){$sql=“SELECT*FROM
{$this->\u table\u 2}
其中
类别
='”$this->db->escape($cat)。“'orderby
date
DESC'”返回$this->db->fetchAll($sql);}您是否在phpmyadmin中运行了此查询并获得了结果?结果为空!我的sql语句与“category”有很大的出入。category是“your_table_name”中的一列。我需要将其与另一个表中的一列进行匹配。我不确定如何编写此查询。它是否为:SELECT*FROM products WHERE category=categories.id ORDER BY date DESC?您是否有两个表要创建ying to
JOIN
?这两个表是如何连接的?我使用这些变量来标识这两个表
private$_table='categories';private$_table_2='products';
products表中的tablecategory列和categories表中的id列的公共列是什么
-- 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!\r\n\r\nRolled 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!\r\n\r\nThis 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. \r\n\r\nIf 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. \r\n\r\nFlavoured 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. \r\n\r\nGG 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.\r\n\r\nThe cooler it is kept, the crunchier the chocolate becomes. \r\n\r\nIf 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 \r\na 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.\r\n\r\nFor schools & clubs the minimum order is 500 bags; for small businesses 100 bags.\r\n\r\nThe 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. \r\n\r\nMini 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. \r\n\r\nEach 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. \r\n\r\nAnother 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. \r\n\r\nLight, tasty, satisfying and not cloying. Long-lasting and made with the best ingredients.\r\n', '8.00', '2014-03-17 08:30:00', 2, 'IrishCremeZoom.jpg'),
(16, 'Ginger Liquorice Nougat', 'Added to the NGL mix for lovers of ginger.\r\nCrystallised ginger and liquorice are melted into nougat fresh from the ovens to give a tasty and beautifully balanced treat.\r\n\r\nThe ginger flavour slowly builds on the palate after about 20 seconds but is never too strong. One or two pieces are all you need.\r\n\r\nA 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.\r\n\r\nRaspberry 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.\r\n\r\nThe 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. \r\n\r\nAnother NZ-made product using the best of ingredients.', '8.00', '2014-03-17 08:34:00', 3, 'PineappleNougatZOOM.jpg'),
(19, 'Liquorice Nougat', 'Eating Ecstasy!\r\n\r\nLike Nougat? Then you''re bound to enjoy this - natural liquorice logs embedded in fresh nougat. \r\n\r\nThe 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...\r\n\r\nThis is a rather soft chewing lolly with the liquorice and aniseed combining to produce subtle flavours. \r\n\r\nIndividually 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 */;
$table1 = "products" ;
$table2 = "categories" ;

SELECT * FROM $table1 LEFT JOIN $table2 ON $table2.`category` = $table1.`id` WHERE $table1.`category` = $cat ORDER BY $table1.`date` DESC