this is my php code:

<? 
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'); 
?>

this is my sql data :


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');

izzit any thing wrg? why i cannot see my result?

Member Avatar for Pityu

First of all put this line into the beggining of the file, to the 2nd line.

include ('database_conn.php');

This:

mysql_connect() or die ("Problem connecting to Database");

must have a form like this:

$myhost = "localhost";
$myuser = "root";
$mypass = "pass";
mysql_connect($myhost, $myuser, $mypass) or die ("Problem connecting to Database");

If you have problems, do not use error_reporting(0); or if you have not disabled the errors, enable all the errors error_reporting(E_ALL);

wow~work d~~~thxxx~

Member Avatar for Pityu

welcome:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.