gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 13:06:53 26 4
gpt4 key购买 nike

通过 phpmyadmin 来 self 的 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>

代码:应该显示我的产品

<div class="catalogue_wrapper_right">
<h4><a href="?page=catalogue-item&amp;category=<?php echo $category['id']; ?>&amp;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>

每次我点击链接时,它都会显示我的错误消息。

如果您能提供任何帮助让这些产品显示在我的网络应用程序上,我们将不胜感激。

这是两个表的 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!\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 */;

最佳答案

在 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

关于php - 尝试在我的 netbeans php 项目中显示我的产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22575090/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com