佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1139|回复: 8

为何米有东西出来的?

[复制链接]
发表于 27-11-2010 03:47 PM | 显示全部楼层 |阅读模式
这个是我的php code:

PHP Syntax (Toggle Plain Text)

  • <?
  • if ($search) // perform search only if a string was entered.
  • {
  • mysql_connect() or die ("Problem connecting to Database");
  • $query = "SELECT shoeName, shoeSize,colour,price,description FROM shoe WHERE gender='$search'";
  • $result = mysql_db_query("CB", $query);
  • if ($result)
  • {
  • echo "Here are the results:<br><br>";
  • echo "<table width=90% align=center border=1><tr>
  • <td align=center bgcolor=#00FFFF>shoe Name</td>
  • <td align=center bgcolor=#00FFFF>shoe Size</td>
  • <td align=center bgcolor=#00FFFF>colour</td>
  • <td align=center bgcolor=#00FFFF>price</td>
  • </tr>";
  • while ($r = mysql_fetch_array($result)) { // Begin while
  • $shoeName = $r["shoeName"];
  • $shoeSize = $r["shoeSize"];
  • $colour = $r["colour"];
  • $price = $r["price"];
  • $description = $r["description"];
  • echo "<tr>
  • <td>$shoeName</td>
  • <td>$shoeSize</td>
  • <td>$colour</td>
  • <td>$price</td></tr>
  • <tr> <td colspan=4 bgcolor=\"#ffffa0\">$description</td>
  • </tr>";
  • } // end while
  • echo "</table>";
  • } else { echo "problems...."; }
  • } else {
  • echo "Search string is empty. <br> Go back and type a string to search";
  • }
  • include ('database_conn.php');
  • ?>


这个是我的sql:


DROP TABLE IF EXISTS brand;
CREATE TABLE IF NOT EXISTS brand (
brandID int(11) NOT NULL AUTO_INCREMENT,
brandName varchar(255) NOT NULL,
PRIMARY KEY (brandID)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--
-- Inserting data for table 'brand'
--

INSERT INTO brand (brandID, brandName) VALUES(1, 'Adidas');
INSERT INTO brand (brandID, brandName) VALUES(2, 'New Balance');
INSERT INTO brand (brandID, brandName) VALUES(3, 'Skechers');
INSERT INTO brand (brandID, brandName) VALUES(4, 'Nike');
INSERT INTO brand (brandID, brandName) VALUES(5, 'Lacoste');

--
-- Creating the table structure for table 'shoe'
--

DROP TABLE IF EXISTS shoe;
CREATE TABLE IF NOT EXISTS shoe (
shoeID int(11) NOT NULL AUTO_INCREMENT,
brandID int(11) NOT NULL,
shoeName varchar(30) DEFAULT NULL,
shoeSize decimal(2,0) DEFAULT NULL,
colour varchar(15) DEFAULT NULL,
gender varchar(6) DEFAULT NULL,
price decimal(5,2) DEFAULT NULL,
description text,
PRIMARY KEY (shoeID)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Inserting data for table 'shoe'
--

INSERT INTO shoe (brandID, shoeName, shoeSize, colour, gender, price, description) VALUES(1, 'Pro Model 86 Remix Shoe, Sneak', 9, 'green', 'male', 75.99, 'The sneaker that helped define the 80s street style. Two-Tone green with orange detailing and laces. Full leather upper with limited edition footbed. Part of the Adidas Remix series.');
INSERT INTO shoe (brandID, shoeName, shoeSize, colour, gender, price, description) VALUES(2, '622 Standard Fit Trainer', 3, 'white', 'female', 50.50, 'NEW BALANCE 622 B FITITNG SHOE The next generation of the 621, the versatile 622 cross trainer is one of the most popular styles. Excellent shock absorption brands this model a perfect choice for most activities on your workout list. A great all rounder for use as a cross trainer or entry level walking shoe, it combines classic styling with ABZORB cushioning in the heel and forefoot with a full leather upper. The shoe is available in different fittings to accommodate all foot shapes.');
INSERT INTO shoe (brandID, shoeName, shoeSize, colour, gender, price, description) VALUES(3, 'Biker - Flower Girl', 5, 'grey', 'female', 35.99, 'SKECHERS CASUAL TRAINES - Really funky designed upper with flower print to the front and back. A great slip on casual sneaker with stitching and overlay accents, patterned fabric and side stripes');
INSERT INTO shoe (brandID, shoeName, shoeSize, colour, gender, price, description) VALUES(1, 'Adidas Training 72 Shoe, Sneak', 11, 'black', 'male', 65.99, 'Released for the 1972 olympics in Munich. Black with white flecks and Tan sockliner. Full Suede upper. These are the Usain Bolt of the footwear world.');
INSERT INTO shoe (brandID, shoeName, shoeSize, colour, gender, price, description) VALUES(4, 'Nike Flytop Mens Trainers', 11, 'brown', 'male', 40.99, 'This is a recent addition to the Nike Hi-Top collection. Velvet Brown. Full Premium Leather Upper with Leather Sock Liner. Nice "Air Flytop" detail on the velcro strap.');
INSERT INTO shoe (brandID, shoeName, shoeSize, colour, gender, price, description) VALUES(5, 'Lacoste Womens Observe Trainer', 7, 'white/red', 'female', 62.99, 'Lacoste patent,check and smooth leather hi-top lace-up trainer. Embroidered branding. Leather and textile upper. Textile lining. Padded ankle. Cushioned insole. Rubber sole and sole surround.');
INSERT INTO shoe (brandID, shoeName, shoeSize, colour, gender, price, description) VALUES(4, 'Nike Air Force 1 Mens Trainers', 11, 'black', 'male', 85.99, 'The Classic Nike sneaker since 1982. Full Leather Upper. Toebox, Swoosh and heel patch are patent leather.');
INSERT INTO shoe (brandID, shoeName, shoeSize, colour, gender, price, description) VALUES(3, 'Luxe', 3, 'black', 'female', 49.99, 'SKECHERS LUXE TRAINER Super stylish casual pump with crossover strap. This features a two tone upper in a mixture of leather and textile. A great casual style with a non slip sole');

那里有错误是吗? 位和他说找不到data的?
回复

使用道具 举报


ADVERTISEMENT

发表于 27-11-2010 04:19 PM | 显示全部楼层
1. 最基础, 也是最烂的写法..
2. 移植性差, 层与层之间重叠, hardcode 问题..
3. 程序是你写的.. 能跑到那一行, 你应该知道..

如果你想等着别人给你答案, 那你就继续等吧..
回复

使用道具 举报

 楼主| 发表于 27-11-2010 04:23 PM | 显示全部楼层
=.= 才刚自己学阿~炸到~但跑到了~wakaakaka~有米有software是专写php code的吗? 因为我用 notepad都不知道错到那一行
回复

使用道具 举报

发表于 27-11-2010 09:47 PM | 显示全部楼层
回复

使用道具 举报

发表于 28-11-2010 01:23 AM | 显示全部楼层
学习一下。。。是不是没链接到server?
21~25是不是多余的?
回复

使用道具 举报

发表于 30-11-2010 01:53 AM | 显示全部楼层
=.= 才刚自己学阿~炸到~但跑到了~wakaakaka~有米有software是专写php code的吗? 因为我用 notepad都不知道 ...
tohobaby 发表于 27-11-2010 04:23 PM



   用dreamweaver lah
回复

使用道具 举报

Follow Us
发表于 8-12-2010 06:36 PM | 显示全部楼层
1. mysql_connect()  。。。server username password 在哪里。。?mysql_connect("server","username","password") .. 另外还需要有mysql_select_db来制定要连接的数据库,
如果有自己写database 的connect function 在database_conn.php里面 ,那么应该用objectname->你的function name 来连接database 。
2. 21-25 确实多余~~
3. editor 和 ide 推荐 phpdesigner ~~
4. 尝试框架 像 codeigniter smarty cakephp 等会让你的编程更加简单和有趣~而且容易培养 OOP思想和MVC模式的了解 。
5. 我也是菜鸟级别,希望高手表骂我~~~
回复

使用道具 举报

发表于 19-12-2010 04:56 PM | 显示全部楼层
用notepad ++ , 会好过你用notepad
回复

使用道具 举报


ADVERTISEMENT

发表于 19-12-2010 08:37 PM | 显示全部楼层
可以的话就写个 UI Helper 帮你生成 Table 就好了咯
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 16-11-2025 03:58 AM , Processed in 0.140347 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表