473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

MySql Select question

can any one tell me what may be wrong with this script I have written, excerpt following:

[PHP]if($set ="yes"){ $query.="online = 'y'"; }
if($lab !=""){ $query.=" AND Lab= '$lab'"; }
if($parcel !=""){ $query.=" AND Parcel = '$parcel'"; }
if($shape !=""){ $query.=" AND Shape = '$shape'"; }
if($color !=""){ $query.=" AND Color = '$color'"; }
if($clarity !=""){ $query.=" AND Clarity = '$clarity'"; }
if($depth !=""){ $query.=" AND Depth = '$depth'"; }
if($size !=""){ $query.=" AND Size = '$size'"; }
if($polish !=""){ $query.=" AND Polish = '$polish'"; }
if($culet !=""){ $query.=" AND Culet = '$culet'"; }
if($fluorescence !=""){ $query.=" AND Fluorescence = '$fluorescence'"; }
if($symmetry !=""){ $query.=" AND Symmetry = '$symmetry'"; }
$query .= " AND Weight BETWEEN '$weight_sm' AND '$weight_big'";

$result = mysql_query("SELECT * FROM diamonds WHERE $query ORDER BY $orderby LIMIT $startrow, $limit")

or die(mysql_error());
[/PHP]

Wieght is all that is working for me?

TIA Ben
Jan 13 '07 #1
2 1122
can any one tell me what may be wrong with this script I have written, excerpt following:

[PHP]if($set ="yes"){ $query.="online = 'y'"; }
if($lab !=""){ $query.=" AND Lab= '$lab'"; }
if($parcel !=""){ $query.=" AND Parcel = '$parcel'"; }
if($shape !=""){ $query.=" AND Shape = '$shape'"; }
if($color !=""){ $query.=" AND Color = '$color'"; }
if($clarity !=""){ $query.=" AND Clarity = '$clarity'"; }
if($depth !=""){ $query.=" AND Depth = '$depth'"; }
if($size !=""){ $query.=" AND Size = '$size'"; }
if($polish !=""){ $query.=" AND Polish = '$polish'"; }
if($culet !=""){ $query.=" AND Culet = '$culet'"; }
if($fluorescence !=""){ $query.=" AND Fluorescence = '$fluorescence'"; }
if($symmetry !=""){ $query.=" AND Symmetry = '$symmetry'"; }
$query .= " AND Weight BETWEEN '$weight_sm' AND '$weight_big'";

$result = mysql_query("SELECT * FROM diamonds WHERE $query ORDER BY $orderby LIMIT $startrow, $limit")

or die(mysql_error());
[/PHP]

Wieght is all that is working for me?

TIA Ben
what is the problem ?
Jan 13 '07 #2
subash
33
Hi,

I think from your code - you may not able to get the online value on certain cases. Its because you have used

[PHP] if($set ="yes"){ $query.="online = 'y'"; } [/PHP]

So always the value has set to "yes"


You need to change this as

[PHP] if($set =="yes"){ $query.="online = 'y'"; } [/PHP]

Are you clear with the comments? - Write back to me

Subash :)
Jan 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Xenophobe | last post by:
I know this isn't a MySQL forum, but my question is related to a PHP project. I have two tables. table1 table2 "table1" contains 2 columns, ID and FirstName:
19
by: Westcoast Sheri | last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database (2 columns: "fruit" and "quantity")....so can we make these following mySQL queries work somehow? (visitor buys 5...
8
by: Tony Clarke | last post by:
Hi, Just a quick question about performance with MySQL & PHP. If I had a table in a MySQL database with about 100,000 records in it and I need to find the last record is there a quick way to do...
1
by: Marcus | last post by:
Hello, quick question about MySQL storing NULL values... Say I have a textbox called $_POST and a variable $var. if(empty($_POST)) $var = NULL; else $var = $_POST; Disregarding...
23
by: phpfrizzle | last post by:
Hi there, I have a site with products on it. The site has a mysql backend. All products belong to certain series (table series). There can be up to 4 different products (table products)...
51
by: w_curtis | last post by:
I'm an Access user, and I'm trying to learn MySQL and then PHP so I can make some web databases. But it just isn't clicking. I've followed some tutorials, and picked up a book, but just getting...
0
by: jy2003 | last post by:
Below is what I got by using MySQL's --log startup option. The original Java(with JDBC driver) program that creates the queries at runtime was coded by other people, and unfortunately, they are not...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
1
by: jlee | last post by:
I'm pretty much a newbie on mysql, and I need some help. I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4 (i386) on a server hosting an active website. The site's developer...
6
by: ojorus | last post by:
Hi! My company make several flash-based games, and I use php to communicate with mysql to provide highscore-lists. My problem is this: When I save a player's score in the mysql-table, I want to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.